示例#1
0
 def testInstanceNotRelevant(self):
     m1 = proj1.Media("1999", "Prince", "1982")
     m2 = proj1.Song("Undo", "Sanna Nielsen", "2014", "No Album", "Pop",
                     190000)
     m3 = proj1.Movie("Inception", "Christopher Nolan", "2010", "PG",
                      8880000)
     self.assertFalse(
         'rating'
         in dir(m1))  #Media does not have 'rating' instance variable
     self.assertFalse(
         'movielength'
         in dir(m1))  #Media does not have 'movie length' instance variable
     self.assertFalse(
         'tracklength'
         in dir(m1))  #Media does not have 'track length' instance variable
     self.assertFalse(
         'rating'
         in dir(m2))  #Song does not have 'rating' instance variable
     self.assertFalse(
         'movielength'
         in dir(m2))  #Song does not have 'movie length' instance variable
     self.assertFalse(
         'tracklength'
         in dir(m3))  #Movie does not have 'track length' instance variable
     self.assertFalse(
         'genre' in dir(m3))  #Movie does not have 'genre' instance variable
     self.assertFalse(
         'album' in dir(m3))  #Movie does not have 'album' instance variable
示例#2
0
def make_media(img):
    """Create a media from an API image information.

    Args:
        img (?): image information obtained from the API
    """
    info = img.imageinfo
    image = media.Media(img.pageid,
                        img.name,
                        width=info['width'],
                        height=info['height'],
                        size=info['size'])
    cats = [cat for cat in img.categories()]
    revs = [rev for rev in img.revisions()]
    # upload date and uploader
    first_revision = revs[-1]
    image.uploader = first_revision['user']
    # qi/fp/vi
    for cat in cats:
        if cat.name == COMMONS_QI_CATEGORY:
            image.quality_image = True
        if cat.name == COMMONS_FP_CATEGORY:
            image.featured_picture = True
        if cat.name == COMMONS_VI_CATEGORY:
            image.valued_image = True
    return image
示例#3
0
 def test__len__(self):
     m1 = proj1.Media("1999", "Prince", "1982")
     m2 = proj1.Song("Undo", "Sanna Nielsen", "2014", "No Album", "Pop",
                     190000)
     m3 = proj1.Movie("Inception", "Christopher Nolan", "2010", "PG",
                      8880000)
     self.assertEqual(m1.__len__(), 0)
     self.assertEqual(m2.__len__(), 190)
     self.assertEqual(m3.__len__(), 148)
示例#4
0
 def test__str__(self):
     m1 = proj1.Media("1999", "Prince", "1982")
     m2 = proj1.Song("Undo", "Sanna Nielsen", "2014", "No Album", "Pop",
                     190000)
     m3 = proj1.Movie("Inception", "Christopher Nolan", "2010", "PG",
                      8880000)
     self.assertEqual(m1.__str__(), "1999 by Prince (1982)")
     self.assertEqual(m2.__str__(), "Undo by Sanna Nielsen (2014) [Pop]")
     self.assertEqual(m3.__str__(),
                      "Inception by Christopher Nolan (2010) [PG]")
示例#5
0
 def __init__(self):
     self.modules = self.get_modules()
     self._media = media.Media()
     self._notification = {
         'power_on': 'assets/ding.wav',
         'callback': 'assets/notification.ogg',
         'power_off': 'assets/dong.wav'
     }
     self._model = 'models/Sas.pmdl'
     self._sensitivity = 0.43
     self._detector = snowboydecoder.HotwordDetector(
         self._model, sensitivity=self._sensitivity)
示例#6
0
 def testConstructor(self):
     m0 = proj1.Media()
     m1 = proj1.Media("1999", "Prince", "1982")
     m2 = proj1.Song("Undo", "Sanna Nielsen", "2014", "No Album", "Pop",
                     190000)
     m3 = proj1.Movie("Inception", "Christopher Nolan", "2010", "PG",
                      8880000)
     self.assertEqual(m0.title, "No Title")
     self.assertEqual(m0.author, "No Author")
     self.assertEqual(m1.title, "1999")
     self.assertEqual(m1.author, "Prince")
     self.assertEqual(m1.releaseyear, "1982")
     self.assertEqual(m2.title, "Undo")
     self.assertEqual(m2.author, "Sanna Nielsen")
     self.assertEqual(m2.releaseyear, "2014")
     self.assertEqual(m2.genre, "Pop")
     self.assertEqual(m2.tracklength, 190000)
     self.assertEqual(m3.title, "Inception")
     self.assertEqual(m3.author, "Christopher Nolan")
     self.assertEqual(m3.releaseyear, "2010")
     self.assertEqual(m3.rating, "PG")
     self.assertEqual(m3.movielength, 8880000)
def generate_movies():
    """
    Generate media instance and append them into an Array, function
    will return that array
    """
    data = parse_data.parse_json_data()
    length = len(data)
    movies = []
    for x in range(0, length):
        da = data[x]
        movies.append(
            media.Media(da["title"], da["description"], da["poster_image_url"],
                        da["trailer_youtube_url"]))
    return movies
示例#8
0
 def runtest(self):
     c = contact.contact()
     c.checkForContacts()
     w = wifi.wifi()
     w.wifiTest()
     n = note.Note()
     n.testNotes()
     a = app.app()
     a.apptest()
     p = photo.photo()
     p.phototest()
     v = video.video()
     v.videotest()
     m = media.Media()
     m.MediaCheck()
示例#9
0
 def __reg(self, t, v):
     if t == "m":
         self.__media = media.Media(
             media_description=entity.MediaDescription.from_string(v))
     elif t == "i":
         pass
     elif t == "c":
         self.__media.connection_data = entity.ConnectionData.from_string(v)
     elif t == "b":
         pass
     elif t == "k":
         pass
     elif t == "a":
         self.__attributes_parser.line(t, v)
     elif t == "$":
         self.__attributes_parser.line(t, v)
         self.__media.attributes = self.__attributes_parser.attributes
     else:
         raise ParseError("Unknown sdp media parameter: " + repr(t) + "=" +
                          repr(v))
示例#10
0
def play():
    a.Resume()
    root.b1.configure(text="Stop", command=stop)


def seek():
    a.Seek(int(root.sp.get()))


def close():
    a.Close()
    root.destroy()


root = tkinter.Tk()
a = media.Media(fd.askopenfilename(initialdir=os.path.expanduser("~")), "r")
l = tkinter.Label(root)
l.pack(fill="both", expand="true")
root.b1 = tkinter.Button(text="Stop", command=stop)
root.b1.pack()
root.b2 = tkinter.Button(text="Close", command=close)
root.b2.pack()
root.sp = tkinter.Spinbox(root, from_=1, to=10, increment=1, width=10)
root.sp.pack()
root.b2 = tkinter.Button(text="Seek", command=seek)
root.b2.pack()
a.Play(audio=0, video=0, audioDevice=None, videoFrame=l)
root.protocol("WM_DELETE_WINDOW", close)
root.mainloop()
a.Close()
示例#11
0
# -*- coding: utf-8 -*-
import media
import fresh_tomatoes

list_movies = [
    media.Media(
        "Wreck-It Ralph",
        "https://image.tmdb.org/t/p/w600_and_h900_bestv2/emJc3atQsh2vnTgogQiyDIHKKPB.jpg",
        "https://youtu.be/watch?v=JPSQOomMWro"),
    media.Media(
        "Avatar",
        "https://image.tmdb.org/t/p/w600_and_h900_bestv2/kmcqlZGaSh20zpTbuoF0Cdn07dT.jpg",
        "https://youtu.be/5PSNL1qE6VY"),
    media.Media(
        "Avengers: Infinity War",
        "https://image.tmdb.org/t/p/w600_and_h900_bestv2/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
        "https://youtu.be/watch?v=6ZfuNTqbHE8"),
    media.Media(
        "Black Panther",
        "https://image.tmdb.org/t/p/w600_and_h900_bestv2/cREN222Yw78zvSQ9bg17Y9QZS0c.jpg",
        "https://youtu.be/watch?v=LqEszt5wG9I"),
    media.Media(
        "The Lord of the Rings: The Fellowship of the Ring",
        "https://image.tmdb.org/t/p/w600_and_h900_bestv2/56zTpe2xvaA4alU51sRWPoKPYZy.jpg",
        "https://youtu.be/watch?v=V75dMMIW2B4"),
    media.Media(
        "Guardians of the Galaxy ",
        "https://image.tmdb.org/t/p/w600_and_h900_bestv2/y31QB9kn3XSudA15tV7UWQ9XLuW.jpg",
        "https://youtu.be/b7yOuhI1dzU")
]
示例#12
0
	'reqCurrentTrack'		: 8,
	'reqCurrentStation'		: 9,
	'reqChangeBand'  		: 10,
	'reqSetHomeAddress'		: 11,
	'reqSetBrightness' 		: 12,
	'reqSetColor'	   		: 13,
	'reqSetContrast'  		: 14,
	'reqSetAddress'	   		: 15,
	'reqGetRecentDestinations': 16
}

messages = []
messages.append(json.dumps({'time': datetime.datetime.utcnow().isoformat() + 'Z'}))


Media = media.Media('media') 
Tuner = tuner.Tuner('tuner') 
Navi = navigation.Navigation('navi')
Settings = settings.Settings('Settings')

def parseMsg(msg):
	try:
		messageObj = json.loads(msg)
	except ValueError:
		LOG.error('Cannot parse message to JSON! ')
		return False
	except:
		LOG.error('Unexpected error: ' + sys.exc_info()[0]); 
		return False
	return messageObj
示例#13
0
import fresh_tomatoes
import media
"""
Author: Vishwajit B.
The purpose of this code is to simply create nine media or movie objects with given parameters.
It then creates a media list and populates the list with these movie objects. After the list
is populated, open_movies_page(thisList) from fresh_tomatoes module is called.
"""
ai = media.Media(
    "Artificial Intelligence",
    "A highly advanced robotic boy longs to become 'real'",
    "https://upload.wikimedia.org/wikipedia/en/e/e6/AI_Poster.jpg",
    "https://www.youtube.com/watch?v=_19pRsZRiz4")

chowka = media.Media(
    "Chowka",
    "Four individuals, each with their own aspirations, land up in jail. ",
    "https://upload.wikimedia.org/wikipedia/en/9/96/Chowka_Poster.jpg",
    "https://www.youtube.com/watch?v=Ugkm8vr0myQ")

ulidavaru = media.Media(
    "Ulidavaru Kandante", "Four lives cross beacuse of a mysterious relic.",
    "https://upload.wikimedia.org/wikipedia/en/5/52/Movie_Poster_of_Ulidavaru_Kandanthe.jpg",
    "https://www.youtube.com/watch?v=POJ_6EtGeMw")

ugramm = media.Media(
    "Ugramm", "A bloody gangster and a naive girl",
    "https://upload.wikimedia.org/wikipedia/en/thumb/4/4f/Ugramm_audio.jpeg/220px-Ugramm_audio.jpeg",
    "https://www.youtube.com/watch?v=qmQEt_MQaLA")

iRobot = media.Media(
示例#14
0
# =====================================================================
# Documentaries_Documentaries_Documentaries_Documentaries_Documentaries
# =====================================================================
cosmos_S1_SL = "A documentary series that explores how we discovered " \
               "the laws of nature and found our " \
               "coordinates in space and time."
cosmos_S1_poster = "https://upload.wikimedia.org/wikipedia/en/8/8e" \
                   "/Cosmos_spacetime_odyssey_titlecard.jpg"
cosmos_trailer = "https://www.youtube.com/watch?v=vbu72k7SbbE"

# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# *************************************OBJECT_DECLARATIONS************@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# ---Movies---Movies---Movies---Movies---Movies---Movies---Movies
dark_skies = media.Media("Dark Skies (Movie)", dark_skies_SL,
                         dark_skies_poster, dark_skies_trailer)

private_ryan = media.Media("Saving Private Ryan (Movie)", private_ryan_SL,
                           private_ryan_poster, private_ryan_trailer)

schindler_list = media.Media("The Schindler's List (Movie)", schindler_list_SL,
                             schindler_list_poster, schindler_list_trailer)

benghazi = media.Media("13 hours (Movie)", benghazi_SL, benghazi_poster,
                       benghazi_trailer)

godfather = media.Media("The Godfather (Movie)", godfather_SL,
                        godfather_poster, godfather_trailer)

angry_birds = media.Media("The Angry Birds (Movie)", angry_birds_SL,
                          angry_birds_poster, angry_birds_trailer)
示例#15
0
    def POST(self):
        try:
            webData = web.data()
            con = db.connectdb()
            print "Handle Post webdata is ", webData
            recMsg = receive.parse_xml(webData)
            is_b = db.check_binding(con, recMsg.FromUserName)
            print(is_b)
            if is_b != 1 and isinstance(
                    recMsg, receive.Msg) and recMsg.MsgType == 'text':
                toUser = recMsg.FromUserName
                fromUser = recMsg.ToUserName
                content = "pull test! git"
                replyMsg = reply.TextMsg(toUser, fromUser, content)
                return replyMsg.send()
            elif isinstance(
                    recMsg,
                    receive.Msg) and recMsg.MsgType == 'text' and is_b == 1:
                print("courseid:" + recMsg.Content)
                db.bind_courese(con, recMsg.FromUserName, recMsg.Content)
                return 'success'

            elif isinstance(recMsg, receive.Msg) and recMsg.MsgType == 'image':
                toUser = recMsg.FromUserName
                fromUser = recMsg.ToUserName
                mediaId = recMsg.MediaId
                print(mediaId)
                replyMsg = reply.ImageMsg(toUser, fromUser, mediaId)
                return replyMsg.send()
            # elif isinstance(recMsg,)
            if isinstance(recMsg, receive.EventMsg):
                if recMsg.Event == 'CLICK':
                    if recMsg.Eventkey == 'mpBind':

                        toUser = recMsg.FromUserName
                        fromUser = recMsg.ToUserName
                        print(toUser)
                        content = "enter course code"
                        replyMsg = reply.TextMsg(toUser, fromUser, content)
                        # con=db.connectdb()
                        db.insert_user(con, toUser)

                        return replyMsg.send()
                    elif recMsg.Eventkey == 'mpState':
                        toUser = recMsg.FromUserName
                        fromUser = recMsg.ToUserName
                        re, len, fn = db.query_ppt(con, toUser)
                        hist.create_hist(len, re, fn)
                        accessToken = Basic().get_access_token()
                        myMedia = media.Media()
                        mediaType = "image"
                        res = myMedia.uplaod(accessToken,
                                             './img/{0}.jpg'.format(fn),
                                             mediaType)
                        data = json.loads(res)
                        media_id = data['media_id']
                        # media_id = 'KPPQWLBPNNqSyWdURe8L8RV0W4yx8zMz18Zp_8k7lsQJ7hMMhilPLlpyidC2YDUL'
                        print(media_id)
                        replyMsg = reply.ImageMsg(toUser, fromUser, media_id)
                        return replyMsg.send()

            # else:
            print "do nothing"
            closedb(db)
            return "success"
        except Exception, Argment:
            return Argment
示例#16
0
    def POST(self):
        try:
            webData = web.data()
            print("Handle Post webdata is ", webData)
            # 后台打日志
            recMsg = receive.parse_xml(webData)
            if recMsg.MsgType == 'event':
                toUser = recMsg.FromUserName
                fromUser = recMsg.ToUserName
                event = recMsg.Event
                if event == 'subscribe':  # 判断如果是关注则进行回复
                    content = "你在池塘里活得很好,泥鳅很丑但会说喜庆话,癞哈蟆很马虎但很有趣,田螺是个温柔的自闭症,小鲫鱼是你们共同的女神。\n有一天你听说,江河湖海,哪个都要更大,更好。\n你跳了出去,遇见了美丽的海豚,雄壮的白鲸,婀娜多姿的热带鱼,的确都是好的。\n\n就是偶尔,觉得世界很空,生活很咸。"
                    replyMsg = reply.TextMsg(toUser, fromUser, content)
                    return replyMsg.send()
            if isinstance(recMsg, receive.Msg) and recMsg.MsgType == 'text':
                toUser = recMsg.FromUserName
                fromUser = recMsg.ToUserName
                input = recMsg.Content.decode(encoding='utf-8')
                # context = ssl._create_unverified_context()
                txt = input.split()
                if txt[0] == "ins" and len(txt) == 2:  # 保存ins图片
                    url = txt[1]
                    r = requests.get(url, params={'__a': 1})

                    try:
                        print("begin")
                        _media = r.json()['graphql']['shortcode_media']
                        if _media['is_video']:
                            print("video")
                            print('Saved as ' + download(_media['display_url'],
                                         _media['shortcode'] + '.mp4') + '!')
                            myMedia = media.Media()
                            accessToken = Basic().get_access_token()
                            filePath = "./img/" + _media['shortcode'] + '.jpg'
                            mediaType = "video"
                            link = myMedia.uplaod(accessToken, filePath, mediaType)
                        else:
                            print("image")
                            if _media.get('edge_sidecar_to_children', None):
                                link = 'You should send a link of picture.'
                                print(link)
                                replyMsg = reply.TextMsg(toUser, fromUser, link)
                                return replyMsg.send()
                                # print('Downloading mutiple images of this post')
                                # for child_node in media['edge_sidecar_to_children']['edges']:
                                #     print('Saved as ' + download(child_node['node']['display_url'],
                                #                                  child_node['node']['shortcode'] + '.jpg') + '!')
                            else:
                                print("1")
                                print('Saved as ' + download(_media['display_url'],
                                         _media['shortcode'] + '.jpg') + '!')
                                myMedia = media.Media()
                                print("media done")
                                accessToken = Basic().get_access_token()
                                filePath = "./img/" + _media['shortcode'] + '.jpg'   # 请按实际填写
                                mediaType = "image"
                                link = myMedia.uplaod(accessToken, filePath, mediaType)
                    except Exception:
                        replyMsg = reply.TextMsg(toUser, fromUser, "Wrong link")
                        return replyMsg.send()

                    replyMsg = reply.ImageMsg(toUser, fromUser, link)
                    return replyMsg.send()

                if txt[0] == 'remind':  # 追剧助手
                    try:
                        if len(txt) == 2:
                            if txt[1] == 'unsubscribe':
                                update_data('data/user.dat', toUser, txt[1] + '\t0')
                                replyMsg = reply.TextMsg(toUser, fromUser, '服务已关闭')
                                return replyMsg.send()
                            elif txt[1] == 'query':
                                query(toUser)
                                replyMsg = reply.TextMsg(toUser, fromUser, '查询完毕')
                                return replyMsg.send()
                            elif txt[1] == 'list':
                                if not os.path.exists('data/catalogue/' + toUser + '.txt'):
                                    replyMsg = reply.TextMsg(toUser, fromUser, "请先提供接收提醒的邮箱")
                                    return replyMsg.send()
                                with open('data/catalogue/' + toUser + '.txt', "r", encoding="utf-8") as f:
                                    ans = ''
                                    for line in f:
                                        word = line.split('\t')
                                        # print(word)
                                        if word[-1] == '1\n':
                                            ans += word[0] + '\n'
                                    if ans == '':
                                        ans = '您还未进行订阅'
                                replyMsg = reply.TextMsg(toUser, fromUser, ans)
                                return replyMsg.send()

                            update_data('data/user.dat', toUser, txt[1] + '\t1')
                            user_catalogue = open('data/catalogue/' + toUser + '.txt', 'w', encoding='utf8')
                            user_record = open('data/record/' + toUser + '.txt', 'w', encoding='utf8')
                            user_catalogue.close()
                            user_record.close()
                            replyMsg = reply.TextMsg(toUser, fromUser, "您的更新提醒将于每天18:00发送至" + txt[1])
                            return replyMsg.send()

                        elif txt[1] == 'add' and len(txt) >= 3:
                            if not os.path.exists('data/catalogue/' + toUser + '.txt'):
                                replyMsg = reply.TextMsg(toUser, fromUser, "请先提供接收提醒的邮箱")
                                return replyMsg.send()
                            keyword = ''
                            for i in range(2, len(txt)):
                                keyword += txt[i] + ' '
                            aim_url = find_episode(keyword)
                            if not aim_url:
                                replyMsg = reply.TextMsg(toUser, fromUser, '未找到您所需的资源')
                                return replyMsg.send()
                            update_data('data/catalogue/' + toUser + '.txt', keyword, aim_url + '\t<font color="#339999">内嵌双语字幕</font>\s*</td>\s*<td>([^>]*)</td>\tutf8\t1')
                            replyMsg = reply.TextMsg(toUser, fromUser, keyword + '的资源地址位于' + aim_url)
                            return replyMsg.send()

                        elif txt[1] == 'delete' and len(txt) >= 3:
                            if not os.path.exists('data/catalogue/' + toUser + '.txt'):
                                replyMsg = reply.TextMsg(toUser, fromUser, "请先提供接收提醒的邮箱")
                                return replyMsg.send()
                            keyword = ''
                            for i in range(2, len(txt)):
                                keyword += txt[i] + ' '
                            aim_url = find_episode(keyword)
                            update_data('data/catalogue/' + toUser + '.txt', keyword, aim_url + '\t<font color="#339999">内嵌双语字幕</font>\s*</td>\s*<td>([^>]*)</td>\tutf8\t0')
                            replyMsg = reply.TextMsg(toUser, fromUser, keyword + '退订成功')
                            return replyMsg.send()

                        else:
                            raise NotImplemented

                    except Exception:
                        replyMsg = reply.TextMsg(toUser, fromUser, "您的输入有误")
                        return replyMsg.send()

                else:
                    # replyMsg = reply.TextMsg(toUser, fromUser, "您的输入有误")
                    # return replyMsg.send()
                    return "success"
            else:
                if recMsg.MsgType == 'image':
                    print(recMsg.MediaId)
                print("暂且不处理")
                return "success"
        except Exception as Argment:
            return Argment
示例#17
0
 def media(self):
     m = media.Media()
     m.MediaCheck()
示例#18
0
# class media which is defined in other file named media.py is going to be like a blueprint
# we are going to import this media class and using its init(i.e constructor) initialise  the object defined in file1

import fresh_tomatoes
import media    

# object 1
avatar = media.Media("Avatar" ,
                     "Because the planet's environment is poisonous,human/Na'vi hybrids,called Avatars, must link to human minds "
                     "to allow for free movement on Pandora. ",
                     "https://www.youtube.com/watch?v=cRdxXPV9GNQ",
                     "images/avatar.jpg");


# object 2

minion = media.Media("Minion",
                     "Evolving from single-celled yellow organisms at the dawn of time,"
                     "Minions live to serve" ,
                     "https://www.youtube.com/watch?v=kkPfdh-XhWg",
                     "images/minions.jpg")

# object 3
lalaland = media.Media("La La Land",
                       "A jazz pianist falls for an aspiring actress in Los Angeles.",
                       "https://www.youtube.com/watch?v=0pdqf4P9MB8",
                       "images/lalaland.jpg")

# object 4
stars = media.Media("Fault In Our Stars",
                    "Two teenage cancer patients begin a life-affirming journey"
示例#19
0
""" Display different movies through Media Class."""

import fresh_tomatoes
import media
""" Finding Nemo movie (an instance of media class):
    movie title, story line, poster image, trailer."""
nemo = media.Media(
    "Finding Nemo",
    "A father fish and his friend cross the ocean to find his lost son",
    "http://img.moviepostershop.com/finding-nemo-movie-poster-2003-1010711355.jpg",  # NOQA
    "https://www.youtube.com/watch?v=3JNLwlcPBPI")
""" Moana movie (an instance of media class):
    movie title, story line, poster image, trailer."""
moana = media.Media(
    "Moana",
    "A brave girl saves her village and the whole world.",
    "https://pbs.twimg.com/media/CygQfgwVIAERyhI.jpg:large",  # NOQA
    "https://www.youtube.com/watch?v=LKFuXETZUsI")
""" Baby Boss movie (an instance of media class):
    movie title, story line, poster image, trailer."""
baby_boss = media.Media(
    "Baby Boss",
    "A baby who leads the world.",
    "http://www.tenterfieldcinema.com.au/wp-content/uploads/2017/01/The-Boss-Baby-poster.jpg",  # NOQA
    "https://www.youtube.com/watch?v=k397HRbTtWI")

# Store movies in an object to be passed to media file
movies = [nemo, moana, baby_boss]

# open website in browser through fresh_tomatoes.py file
fresh_tomatoes.open_movies_page(movies)
示例#20
0
# Set language and country configuration for API data
set_locale('en', 'us')


now_playing = []
coming_soon = []
modern_classics = []
classics = []


for x in range(0, len(List(35555).members)):
    media_title = List(35555).members[x].title.replace(' ', '_')
    media_title = media.Media(
        List(35555).members[x].title,
        List(35555).members[x].poster.geturl().replace(
            'original', 'w300_and_h450_bestv2'),
        List(35555).members[x].youtube_trailers[0].geturl(),
        List(35555).members[x].userrating
        )

    now_playing.append(media_title)


for y in range(0, len(List(35556).members)):
    media_title = List(35556).members[y].title.replace(' ', '_')
    media_title = media.Media(
        List(35556).members[y].title,
        List(35556).members[y].poster.geturl().replace(
            'original', 'w300_and_h450_bestv2'),
        List(35556).members[y].youtube_trailers[0].geturl(),
        List(35556).members[y].userrating
示例#21
0
# py version        : 3.8.2 (must run on 3.6 or higher)
#==============================================================================
import os
from threading import Thread
import requests
from requests.exceptions import *
from urllib3.exceptions import SSLError
from scraper import Scraper
from stream import Stream
import config as cfg
import media
from media import log

headers = {"user-agent": cfg.user_agent}
resolution_list = cfg.video_quality
media_files = media.Media("MOVIES")
home = os.getcwd()
requests.adapters.HTTPAdapter(max_retries=cfg.max_retries)


def url_format(url, target_res, old_res="360"):
    url = url.replace(f"/{old_res}?name=", f"/{target_res}?name=")
    url = url.replace(f"_{old_res}&token=ip=", f"_{target_res}&token=ip=")
    return url


def validate_url(url, target_res=None):
    if target_res:
        url = url_format(url, target_res)
    error_message = ""
    try:
示例#22
0
    def post(self):
        try:
            webData = self.request.body
            # 后台打日志
            recMsg = receive.parse_xml(webData)
            if isinstance(recMsg, receive.Msg) and recMsg.MsgType == 'text':
                if recMsg.Content == '#SCAPK':
                    toUser = recMsg.FromUserName
                    fromUser = recMsg.ToUserName
                    content = "http://www.zoujingyi.cn/app-release.apk"

                    qrcodePath = "imgs/release_apk_qrcode.png"
                    img = qrcode.make(content)
                    img.save(qrcodePath)
                    myMedia = media.Media()
                    accessToken = basic.Basic().get_access_token()
                    path = "/home/zou/WechatDetector/" + qrcodePath
                    mediaType = "image"
                    back = myMedia.uplaod(accessToken, path, mediaType)
                    back_json = json.loads(back)
                    media_id = back_json["media_id"]
                    replyMsg = reply.ImageMsg(toUser, fromUser, media_id)
                    self.write(replyMsg.send())

                elif recMsg.Content == '#OPENID':
                    toUser = recMsg.FromUserName
                    fromUser = recMsg.ToUserName
                    content = toUser

                    qrcodePath = "imgs/" + toUser + "_qrcode.png"
                    img = qrcode.make(content)
                    img.save(qrcodePath)

                    myMedia = media.Media()
                    accessToken = basic.Basic().get_access_token()
                    path = "/home/zou/WechatDetector/" + qrcodePath
                    mediaType = "image"
                    back = myMedia.uplaod(accessToken, path, mediaType)
                    back_json = json.loads(back)
                    media_id = back_json["media_id"]
                    replyMsg = reply.ImageMsg(toUser, fromUser, media_id)
                    self.write(replyMsg.send())
                elif recMsg.Content == '#DEVICE':
                    toUser = recMsg.FromUserName
                    fromUser = recMsg.ToUserName
                    content = ""
                    deviceIds = db.select_user(toUser)[2]
                    if deviceIds is not None:
                        for id in deviceIds.split(","):
                            deviceName = db.select_deviceName(deviceId=id)[1]
                            content = content + deviceName + " " + id + "\n"
                    replyMsg = reply.TextMsg(toUser, fromUser, content)
                    self.write(replyMsg.send())
                elif tool.fullmatch(r"(\d{4}-\d{1,2}-\d{1,2}\|\d+)",
                                    recMsg.Content):
                    # 日期|deviceId
                    toUser = recMsg.FromUserName
                    fromUser = recMsg.ToUserName
                    balance = int(db.select_user(user_name=toUser)[1])
                    if balance < price:
                        content = "余额不足,请充值,您的余额为" + str(balance) + "元"
                        replyMsg = reply.TextMsg(toUser, fromUser, content)
                        self.write(replyMsg.send())
                    else:
                        handleDate(recMsg=recMsg,
                                   handler=self,
                                   balance=balance)
            else:
                print("暂且不处理")
                self.write("success")
        except Exception as e:
            print(e)