Beispiel #1
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        info.title = match1(html, '<title>([^<]+)').split('_')[0]

        video_name = match1(html, 'getFlash\("[0-9]+","([^"]+)')
        params = { 'streamtype':'live',
                   'VideoIDS': video_name,
                   'cdns' : '1'
                }
        form = urlencode(params)
        content = get_content(self.live_base,data=compact_bytes(form, 'utf-8'),charset = 'utf-8')
        stream_data = json.loads(content)

        assert stream_data["roomStatus"] == "1", "The live stream is not online! "
        for stream in stream_data["streamList"]:
            if stream['default'] == 1:
                defstream = stream['list']

        for stream in defstream:
            info.stream_types.append(stream['type'])
            info.streams[stream['type']] = {'container': 'flv', 'video_profile': self.stream_2_profile[stream['type']], 'src' : [stream['url']], 'size': float('inf')}

        info.stream_types = sorted(info.stream_types, key = self.supported_stream_types.index)
        return info
Beispiel #2
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        info.title = match1(html, '<title>([^<]+)').split('_')[0]

        data = json.loads(match1(html, 'channelOneInfo = ({.+?});'))
        tag_from = 'huomaoh5room'
        tn = str(int(time.time()))
        sign_context = data['stream'] + tag_from + tn + SECRETKEY
        token = hashlib.md5(compact_bytes(sign_context, 'utf-8')).hexdigest()

        params = { 'streamtype':'live',
                   'VideoIDS': data['stream'],
                   'time': tn,
                   'cdns' : '1',
                   'from': tag_from,
                   'token': token
                }
        content = get_content(self.live_base, data=compact_bytes(urlencode(params), 'utf-8'), charset='utf-8')
        stream_data = json.loads(content)

        assert stream_data["roomStatus"] == "1", "The live stream is not online! "
        for stream in stream_data["streamList"]:
            if stream['default'] == 1:
                defstream = stream['list']

        for stream in defstream:
            info.stream_types.append(stream['type'])
            info.streams[stream['type']] = {'container': 'flv', 'video_profile': self.stream_2_profile[stream['type']], 'src' : [stream['url']], 'size': float('inf')}

        info.stream_types = sorted(info.stream_types, key = self.supported_stream_types.index)
        return info
Beispiel #3
0
 def letvcloud_download_by_vu(self):
     info = VideoInfo(self.name)
     #ran = float('0.' + str(random.randint(0, 9999999999999999))) # For ver 2.1
     #str2Hash = 'cfflashformatjsonran{ran}uu{uu}ver2.2vu{vu}bie^#@(%27eib58'.format(vu = vu, uu = uu, ran = ran)  #Magic!/ In ver 2.1
     vu, uu = self.vid
     argumet_dict ={'cf' : 'flash', 'format': 'json', 'ran': str(int(time.time())), 'uu': str(uu),'ver': '2.2', 'vu': str(vu), }
     sign_key = '2f9d6924b33a165a6d8b5d3d42f4f987'  #ALL YOUR BASE ARE BELONG TO US
     str2Hash = ''.join([i + argumet_dict[i] for i in sorted(argumet_dict)]) + sign_key
     sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
     html = get_content('http://api.letvcloud.com/gpc.php?' + '&'.join([i + '=' + argumet_dict[i] for i in argumet_dict]) + '&sign={sign}'.format(sign = sign), charset= 'utf-8')
     data = json.loads(html)
     assert data['code'] == 0, data['message']
     video_name = data['data']['video_info']['video_name']
     if '.' in video_name:
         ext = video_name.split('.')[-1]
         info.title = video_name[0:-len(ext)-1]
     else:
         ext = 'mp4'
         info.title = video_name
     available_stream_type = data['data']['video_info']['media'].keys()
     for stream in self.supported_stream_types:
         if stream in available_stream_type:
             urls = [base64.b64decode(data['data']['video_info']['media'][stream]['play_url']['main_url']).decode("utf-8")]
             info.stream_types.append(stream)
             info.streams[stream] = {'container': ext, 'video_profile': stream, 'src': urls, 'size' : 0}
     return info
Beispiel #4
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, '/(\d+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"liveAddr":"([0-9\_]+)"')
        self.pid = self.vid

        # from upstream!!
        serverDataTxt = match1(html, 'serverData = {([\S\ ]+)};')
        serverDataTxt = '{%s}' % (serverDataTxt)
        self.logger.debug("serverDataTxt => %s" % (serverDataTxt))

        serverData = json.loads(serverDataTxt)
        self.logger.debug(serverData)

        assert serverData["liveInfo"]["data"]["profileInfo"]["isLive"] == 1, 'error: live show is not on line!!'

        info.title = serverData["liveInfo"]["data"]["videoInfo"]["title"]
        info.artist = serverData["liveInfo"]["data"]["profileInfo"]["nickName"]

        for data in serverData["liveInfo"]["data"]["videoInfo"]["streamInfos"]:
            info.stream_types.append(self.bitrate_2_type[data["bitrate"]])
            info.streams[self.bitrate_2_type[data["bitrate"]]] = {'container': 'flv', 'video_profile': data["desc"], 'src': ["%s&_t=%s000"%(unescape(data["playUrl"]),int(time.time()))], 'size': float('inf')}

        return info
Beispiel #5
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, 'channel=([\d]+)')

        live_data = json.loads(get_content('http://api.live.letv.com/v1/channel/letv/100/1001/{}'.format(self.vid)))['data']

        info.title = self.name + " " + live_data['channelName']

        stream_data = live_data['streams']

        for s in stream_data:
            stream_id = self.stream_2_id[s['rateType']]
            stream_profile = self.stream_2_profile[s['rateType']]
            if not stream_id in info.stream_types:
                info.stream_types.append(stream_id)
                date = datetime.datetime.now()
                streamUrl = s['streamUrl'] + '&format=1&expect=2&termid=1&hwtype=un&platid=10&splatid=1001&playid=1sign=live_web&&ostype={}&p1=1&p2=10&p3=-&vkit={}&station={}&tm={}'.format(platform.platform(), date.strftime("%Y%m%d"), self.vid, int(time.time()))
                data = json.loads(get_content(streamUrl))
                nodelist = data['nodelist']
                for node in nodelist:
                    src = node['location']
                    try:
                        get_content(src)
                        info.streams[stream_id] = {'container': 'm3u8', 'video_profile': stream_profile, 'size' : float('inf'), 'src' : [src]}
                    except:
                        continue
                    break
        info.stream_types = sorted(info.stream_types, key = self.stream_ids.index)
        return info
Beispiel #6
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        ID = match1(self.url, "/(\d+)")
        api1_data = json.loads(get_content("{}?id={}".format(api1_url, ID)))
        self.vid = api1_data["data"]["room_id"]
        api2_data = json.loads(get_content("{}?room_id={}&from=room".format(api2_url, self.vid)))
        info.title = api2_data["data"]["title"]
        assert api2_data["data"]["live_status"] == 1, u"主播正在觅食......"

        def get_live_info(q=0):
            data = json.loads(get_content("{}?player=1&cid={}&quality={}&otype=json".format(api_url, self.vid, q)))

            assert data["code"] == 0, data["msg"]

            data = data["data"]
            urls = [random.choice(data["durl"])["url"]]
            qlt = data['current_quality']
            aqlts = [int(x) for x in data['accept_quality']]
            size = float('inf')
            ext = 'flv'
            prf = self.supported_stream_profile[4 - qlt]
            st = self.profile_2_type[prf]
            if urls and st not in info.streams:
                info.stream_types.append(st)
                info.streams[st] = {'container': ext, 'video_profile': prf, 'src' : urls, 'size': size}

            if q == 0:
                aqlts.remove(qlt)
                for aqlt in aqlts:
                    get_live_info(aqlt)

        get_live_info()
        return info
Beispiel #7
0
    def prepare(self):
        info = VideoInfo(self.name)
        add_header("Referer", "http://music.163.com/")
        if not self.vid:
            self.vid =  match1(self.url, 'song/(\d+)', '\?id=(.*)')
        api_url = self.api_url.format(self.vid, self.vid)
        music = self.get_music(json.loads(get_content(api_url)))
        self.logger.debug("music info >" + str(music))
        info.title = music['name']
        info.artist = music['artists'][0]['name']

        real_id = music["id"]

        snd_key = random_string()
        if sys.version_info[0] == 3:
            encSecKey = RSA_string(snd_key)
        else:
            encSecKey = RSA_string(snd_key)[:-1]
        payload = netease_req(real_id, snd_key, encSecKey)

        mp3_info = json.loads(get_content(self.mp3_api, data=compact_bytes(urlencode(payload), 'utf-8')))['data'][0]
        self.logger.debug("mp3 > " + str(mp3_info))
        info.stream_types.append('current')
        info.streams['current'] =  {'container': mp3_info['type'], 'video_profile': 'current', 'src' : [mp3_info['url']], 'size': mp3_info['size']}
        return info
Beispiel #8
0
    def prepare(self):
        self.vid = match1(self.url, 'd=(\d+)', 'live/(\d+)')
        if '/izt/' in self.url:
            vid = self.vid
            if not vid:
                html = get_content(self.url)
                vid = match1(html, 'vid\s*:\s*"(\d+)",', 'vid="(\d+)"')
            return get_playback(vid)
        else:
            if not self.vid:
                html = get_content(self.url)
                self.vid = match1(html, 'liveId\s*:\s*"(\d+)"')

        live_data = json.loads(get_content('http://api.live.letv.com/v1/liveRoom/single/1001?id={}'.format(self.vid)))
        if live_data.get('status') != 2:
            return get_playback(live_data['recordingId'])

        # live video is dead, the followed code will not be used
        live_data = json.loads(get_content('http://player.pc.le.com/player/startup_by_pid/1001/{}?host=live.le.com'.format(self.vid)))

        info = VideoInfo(self.name, True)
        info.title = live_data['title']
        stream_data = live_data['rows']

        for s in stream_data:
            stream_id = self.stream_2_id[s['rateType']]
            stream_profile = self.stream_2_profile[s['rateType']]
            if not stream_id in info.stream_types:
                info.stream_types.append(stream_id)
                streamUrl = s['streamUrl'] + '&format=1&expect=2&termid=1&platid=10&playid=1&sign=live_web&splatid=1001&vkit=20161017&station={}'.format( self.vid)
                data = json.loads(get_content(streamUrl))
                src = data['location']
                info.streams[stream_id] = {'container': 'm3u8', 'video_profile': stream_profile, 'size' : float('inf'), 'src' : [src]}
        info.stream_types = sorted(info.stream_types, key = self.stream_ids.index)
        return info
Beispiel #9
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if self.url:
            self.vid = match1(self.url, '/(\d+)')

        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"room_id.?":(\d+)')

        for stream in self.stream_ids:
            tt = int(time.time())
            rate = self.stream_id_2_rate[stream]
            signContent = 'lapi/live/thirdPart/getPlay/{}?aid=pcclient&rate={}&time={}9TUk5fjjUjg9qIMH3sdnh'.format(self.vid, rate , tt)
            sign = md5(signContent.encode('utf-8')).hexdigest()
            url = 'http://coapi.douyucdn.cn/lapi/live/thirdPart/getPlay/{}?rate={}'.format(self.vid, rate)

            html_content = get_content(url, headers = {		'auth': sign, 'time': str(tt), 'aid': 'pcclient' })
            live_data = json.loads(html_content)['data']

            real_url = live_data['live_url']

            info.stream_types.append(stream)
            info.streams[stream] = {'container': 'flv', 'video_profile': self.id_2_profile[stream], 'src' : [real_url], 'size': float('inf')}
            info.title = live_data['room_name']
        return info
Beispiel #10
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, '/(\d+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"room_id":(\d+)')

        #from upstream!!
        api_url = 'http://www.qie.tv/api/v1/room/{}'.format(self.vid)

        metadata = json.loads(get_content(api_url))
        assert metadata['error'] == 0, 'error {}: {}'.format(metadata['error'], metadata['data'])

        livedata = metadata['data']
        assert livedata['show_status'] == '1', 'error: live show is not on line!!'

        info.title = livedata['room_name']
        info.artist = livedata['nickname']

        base_url = livedata['rtmp_url']

        if 'hls_url' in livedata:
            info.stream_types.append('BD')
            info.streams['BD'] = {'container': 'm3u8', 'video_profile': u'原画', 'src' : [livedata['hls_url']], 'size': float('inf')}

        mutli_stream = livedata['rtmp_multi_bitrate']
        for i in self.mutli_bitrate:
            if i in mutli_stream:
                info.stream_types.append(self.bitrate_2_type[i])
                info.streams[self.bitrate_2_type[i]] = {'container': 'flv', 'video_profile': self.bitrate_2_profile[i], 'src' : [base_url + '/' + mutli_stream[i]], 'size': float('inf')}
        return info
Beispiel #11
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 'video_id:\'([^\']+)') or match1(self.url, '#(\d+)')

        assert self.vid, "can't get vid"

        api_url = 'http://s.video.sina.com.cn/video/h5play?video_id={}'.format(self.vid)
        data = json.loads(get_content(api_url))['data']
        info.title = data['title']
        for t in ['mp4', '3gp', 'flv']:
            if t in data['videos']:
                video_info = data['videos'][t]
                break

        for profile in video_info:
            if not profile in info.stream_types:
                v = video_info[profile]
                tp = v['type']
                url = v['file_api']+'?vid='+v['file_id']
                r_url = get_realurl(url)
                info.stream_types.append(profile)
                info.streams[profile] = {'container': tp, 'video_profile': profile, 'src': [r_url], 'size' : 0}
        return info
Beispiel #12
0
    def parser_list(self, url):
        add_header("Referer", "http://music.163.com/")
        vid =  match1(url, 'id=(.*)')
        if "album" in url:
           api_url = "http://music.163.com/api/album/{}?id={}&csrf_token=".format(vid, vid)
           listdata = json.loads(get_content(api_url))
           playlist = listdata['album']['songs']
        elif "playlist" in url:
           api_url = "http://music.163.com/api/playlist/detail?id={}&csrf_token=".format(vid)
           listdata = json.loads(get_content(api_url))
           playlist = listdata['result']['tracks']
        elif "toplist" in url:
           api_url = "http://music.163.com/api/playlist/detail?id={}&csrf_token=".format(vid)
           listdata = json.loads(get_content(api_url))
           playlist = listdata['result']['tracks']
        elif "artist" in url:
           api_url = "http://music.163.com/api/artist/{}?id={}&csrf_token=".format(vid, vid)
           listdata = json.loads(get_content(api_url))
           playlist = listdata['hotSongs']

        info_list = []
        for music in playlist:
            info = VideoInfo(self.name)
            info.title = music['name']
            info.artist = music['artists'][0]['name']
            self.mp3_host = music['mp3Url'][8]
            for st in self.supported_stream_types:
                if st in music and music[st]:
                    info.stream_types.append(st)
                    self.song_date[st] = music[st]
            self.extract_song(info)
            info_list.append(info)
        return info_list
Beispiel #13
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            self.vid = match1(self.url, '/show(?:/channel)?/([^\./]+)',
                                        '/media/([^\./]+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 's[cm]id ?= ?[\'"]([^\'"]+)[\'"]')
        assert self.vid, "No VID match!"

        data = json.loads(get_content('https://n.miaopai.com/api/aj_media/info.json?smid={}'.format(self.vid)))
        if 'status' in data:
            if data['status'] != 200:
                data = json.loads(get_content('http://api.miaopai.com/m/v2_channel.json?fillType=259&scid={}&vend=miaopai'.format(self.vid)))

            assert data['status'] == 200, data['msg']

            data = data['result']
            info.title = data['ext']['t'] or self.name + '_' + self.vid
            url = data['stream']['base']
            ext = data['stream']['and']
        else:
            assert data['code'] == 200, data['msg']

            data = data['data']
            info.title = data['description'] or self.name + '_' + self.vid
            url = data['meta_data'][0]['play_urls']['m']
            _, ext, _ = url_info(url)

        info.stream_types.append('current')
        info.streams['current'] = {'container': ext or 'mp4', 'src': [url], 'size' : 0}
        return info
Beispiel #14
0
    def prepare(self):
        info = VideoInfo(self.name)
        if self.url and not self.vid:
            self.vid = match1(self.url, 'http://v.ku6.com/special/show_\d+/(.*)\.html',
            'http://v.ku6.com/show/(.*)\.html',
            'http://my.ku6.com/watch\?.*v=(.*).*')

        video_data = json.loads(get_content('http://v.ku6.com/fetchVideo4Player/%s.html' % self.vid))
        data = video_data['data']
        assert video_data['status'] == 1, '%s : %s' % (self.name, data)
        info.title = data['t']
        f = data['f']


        urls = f.split(',')
        ext = re.sub(r'.*\.', '', urls[0])
        assert ext in ('flv', 'mp4', 'f4v'), ext
        ext = {'f4v': 'flv'}.get(ext, ext)
        size = 0
        for url in urls:
            _, _, temp = url_info(url)
            size += temp

        info.streams['current'] = {'container': ext, 'src': urls, 'size' : size}
        info.stream_types.append('current')
        return info
Beispiel #15
0
Datei: mgtv.py Projekt: flfq/ykdl
    def prepare(self):
        info = VideoInfo(self.name)
        if self.url and not self.vid:
            self.vid = match1(self.url, 'http://www.mgtv.com/b/\d+/(\d+).html')
            if self.vid is None:
                html = get_content(self.url)
                self.vid = match1(html, 'vid=(\d+)', 'vid=\"(\d+)', 'vid: (\d+)')

        api_url = 'http://pcweb.api.mgtv.com/player/video?video_id={}'.format(self.vid)
        meta = json.loads(get_content(api_url))

        assert meta['code'] == 200, '[failed] status: {}, msg: {}'.format(meta['status'],meta['msg'])
        assert meta['data'], '[Failed] Video not found.'

        data = meta['data']

        info.title = data['info']['title']
        domain = data['stream_domain'][0]
        for lstream in data['stream']:
            if lstream['url']:
                url = json.loads(get_content(domain + lstream['url']))['info']
                info.streams[self.profile_2_types[lstream['name']]] = {'container': 'm3u8', 'video_profile': lstream['name'], 'src' : [url]}
                info.stream_types.append(self.profile_2_types[lstream['name']])
        info.stream_types= sorted(info.stream_types, key = self.supported_stream_types.index)
        return info
Beispiel #16
0
Datei: live.py Projekt: flfq/ykdl
    def prepare(self):
        info = VideoInfo(self.name, True)

        if not self.vid:
            html = get_content(self.url)
            room = match1(html, 'var $ROOM = ([^;]+)')
            self.vid = match1(html, '"room_id.?":(\d+)')
            info.title = json.loads("{\"room_name\" : \"" + match1(html, '"room_name.?":"([^"]+)') + "\"}")['room_name']
            info.artist = json.loads("{\"name\" : \"" + match1(html, '"owner_name.?":"([^"]+)') + "\"}")['name']
        api_url = 'https://www.douyu.com/lapi/live/getPlay/{}'.format(self.vid)
        tt = str(int(time.time() / 60))
        rnd_md5 = hashlib.md5(str(random.random()).encode('utf8'))
        did = rnd_md5.hexdigest().upper()
        to_sign = ''.join([self.vid, did, API_KEY, tt])
        sign = stupidMD5(to_sign)
        for stream in self.stream_ids:
            rate = self.stream_id_2_rate[stream]
            params = {"ver" : VER, "sign" : sign, "did" : did, "rate" : rate, "tt" : tt, "cdn" : "ws"}
            form = urlencode(params)
            html_content = get_content(api_url, data=compact_bytes(form, 'utf-8'))
            live_data = json.loads(html_content)
            assert live_data["error"] == 0, "live show is offline"
            live_data = live_data["data"]
            real_url = '/'.join([live_data['rtmp_url'], live_data['rtmp_live']])

            info.stream_types.append(stream)
            info.streams[stream] = {'container': 'flv', 'video_profile': self.id_2_profile[stream], 'src' : [real_url], 'size': float('inf')}

        return info
Beispiel #17
0
    def prepare(self):
        info = VideoInfo(self.name)
        add_header("Referer", "http://www.bilibili.com")
        info.extra["referer"] = "http://www.bilibili.com"
        info.extra["ua"] = fake_headers['User-Agent']
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 'cid=(\d+)', 'cid=\"(\d+)')
            info.title = match1(html, '<title>([^<]+)').split("_")[0].strip(u" 番剧 bilibili 哔哩哔哩弹幕视频网")
            if not self.vid:
                eid = match1(self.url, 'anime/v/(\d+)', 'play#(\d+)') or match1(html, 'anime/v/(\d+)')
                if eid:
                    Episode_info = json.loads(get_content('http://bangumi.bilibili.com/web_api/episode/{}.json'.format(eid)))['result']['currentEpisode']
                    self.vid = Episode_info['danmaku']
                    info.title = info.title + ' ' + Episode_info['indexTitle'] + '.  ' + Episode_info['longTitle']

        assert self.vid, "can't play this video: {}".format(self.url)
        for q in self.supported_stream_profile:
            sign_this = hashlib.md5(compact_bytes('cid={}&from=miniplay&player=1&quality={}{}'.format(self.vid, 3-self.supported_stream_profile.index(q), SECRETKEY_MINILOADER), 'utf-8')).hexdigest()
            api_url = 'http://interface.bilibili.com/playurl?cid={}&player=1&quality={}&from=miniplay&sign={}'.format(self.vid, 3-self.supported_stream_profile.index(q), sign_this)
            html = get_content(api_url)
            self.logger.debug("HTML> {}".format(html))
            urls, size, ext = parse_cid_playurl(html)
            if ext == 'hdmp4':
                ext = 'mp4'

            info.stream_types.append(self.profile_2_type[q])
            info.streams[self.profile_2_type[q]] = {'container': ext, 'video_profile': q, 'src' : urls, 'size': size}
        return info
Beispiel #18
0
    def prepare(self):
        info = VideoInfo(self.name)
        stream_temp = {'1080p': None , '1300': None, '1000':None , '720p': None, '350': None }
        self.__STREAM_TEMP__.append(stream_temp)
        if not self.vid:
            self.vid = match1(self.url, r'http://www.le.com/ptv/vplay/(\d+).html', '#record/(\d+)')

        #normal process
        info_url = 'http://api.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com'.format(self.vid, calcTimeKey(int(time.time())))
        r = get_content(info_url)
        data=json.loads(r)

        info.title = data['playurl']['title']
        available_stream_id = sorted(list(data["playurl"]["dispatch"].keys()), key = self.supported_stream_types.index)
        for stream in available_stream_id:
            s_url =data["playurl"]["domain"][0]+data["playurl"]["dispatch"][stream][0]
            s_url+="&ctv=pc&m3v=1&termid=1&format=1&hwtype=un&ostype=Linux&tag=le&sign=le&expect=3&tn={}&pay=0&iscpn=f9051&rateid={}".format(random.random(),stream)
            r2=get_content(s_url)
            data2=json.loads(r2)

            # hold on ! more things to do
            # to decode m3u8 (encoded)
            m3u8 = get_content(data2["location"], charset = 'ignore')
            m3u8_list = decode(m3u8)
            stream_id = self.stream_2_id[stream]
            info.streams[stream_id] = {'container': 'm3u8', 'video_profile': self.stream_2_profile[stream], 'size' : 0}
            stream_temp[stream] = compact_tempfile(mode='w+t', suffix='.m3u8')
            stream_temp[stream].write(m3u8_list)
            info.streams[stream_id]['src'] = [stream_temp[stream].name]
            stream_temp[stream].flush()
            info.stream_types.append(stream_id)
        return info
Beispiel #19
0
    def prepare(self):
        info = VideoInfo(self.name, True)

        ID = match1(self.url, '/(\d+)')
        api1_data = json.loads(get_content(api1_url.format(ID)))
        if api1_data['code'] == 0:
            self.vid = api1_data['data']['room_id']
        else:
            self.logger.debug('Get room ID from API failed: %s', api1_data['msg'])
            self.vid = ID

        api2_data = json.loads(get_content(api2_url.format(self.vid)))
        assert api2_data['code'] == 0, api2_data['msg']
        api2_data = api2_data['data']
        assert api2_data['live_status'] == 1, u'主播正在觅食......'
        info.title = title = api2_data['title']

        api3_data = json.loads(get_content(api3_url.format(self.vid)))
        if api3_data['code'] == 0:
            info.artist = artist = api3_data['data']['info']['uname']
            info.title = '{} - {}'.format(title, artist)

        def get_live_info(q=0):
            params = {
                'player': 1,
                'cid': self.vid,
                'platform': 'html5',
                'quality': q,
                'otype': 'json'
            }
            data = json.loads(get_content(api_url + urlencode(params)))

            assert data['code'] == 0, data['message']

            data = data['data']
            urls = [random.choice(data['durl'])['url']]
            qlt = data['current_quality']
            aqlts = [int(x) for x in data['accept_quality']]
            size = float('inf')
            ext = 'flv'
            prf = self.supported_stream_profile[4 - qlt]
            st = self.profile_2_type[prf]
            if urls and st not in info.streams:
                info.stream_types.append(st)
                info.streams[st] = {
                    'container': ext,
                    'video_profile': prf,
                    'src' : urls,
                    'size': size
                }

            if q == 0:
                aqlts.remove(qlt)
                for aqlt in aqlts:
                    get_live_info(aqlt)

        get_live_info()
        info.stream_types = sorted(info.stream_types, key=self.sorted_format.index)
        return info
Beispiel #20
0
    def prepare(self):
        if self.url and not self.vid:
            self.vid = match1(self.url, '\Wvid=(\d+)', '\Wid=(\d+)',
                              '\Wbid=(\d+)', 'share_play.html#(\d+)_')
            if not self.vid:
                html = get_content(self.url)
                self.vid = match1(html, '/(\d+)/v\.swf', 'vid="(\d+)"',
                                  '\&id=(\d+)')
        self.logger.debug("VID> {}".format(self.vid))

        info = json.loads(get_content(self.apiurl % self.vid))
        self.logger.debug("info> {}".format(info))
        if info['status'] == 6:
            self.name = u'搜狐自媒体 (MySohu)'
            self.apiurl = 'http://my.tv.sohu.com/play/videonew.do?vid=%s&referer=http://my.tv.sohu.com'
            info = json.loads(get_content(self.apiurl % self.vid))
            self.logger.debug("info> {}".format(info))

        video = VideoInfo(self.name)
        # this is needless now, uid well be registered in the the following code
        #video.extra["header"] = "Range: "
        if info['status'] == 1:
            now = time.time()
            uid = int(now * 1000)
            params = {
                'vid': self.vid,
                'url': self.url,
                'refer': self.url,
                't': int(now),
                'uid': uid,
                #'nid': nid,
                #'pid': pid,
                #'screen': '1366x768',
                #'channeled': channeled,
                #'MTV_SRC': MTV_SRC,
                #'position': 'page_adbanner',
                #'op': 'click',
                #'details': '{}',
                #'os': 'linux',
                #'platform': 'linux',
                #'passport': '',
            }
            get_content('http://z.m.tv.sohu.com/h5_cc.gif?' +
                        urlencode(params))

            data = info['data']
            video.title = data['tvName']
            for stream in self.supported_stream_types:
                lvid = data.get(stream)
                if lvid == 0 or not lvid:
                    continue
                if lvid != self.vid:
                    _info = json.loads(get_content(self.apiurl % lvid))
                    self.logger.debug("info> {}".format(_info))
                else:
                    _info = info

                self.parser_info(video, _info, stream, lvid, uid)
        return video
Beispiel #21
0
    def prepare(self):
        if self.url and not self.vid:
            self.vid = match1(self.url, '\Wvid=(\d+)', '\Wid=(\d+)', 'share_play.html#(\d+)_')
            if not self.vid:
                html = get_content(self.url)
                self.vid = match1(html, '/(\d+)/v\.swf', 'vid="(\d+)"', '\&id=(\d+)')
        self.logger.debug("VID> {}".format(self.vid))

        info = json.loads(get_content(self.apiurl % self.vid))
        self.logger.debug("info> {}".format(info))
        if info['status'] == 6:
            self.name = u'搜狐自媒体 (MySohu)'
            self.apiurl = 'http://my.tv.sohu.com/play/videonew.do?vid=%s&referer=http://my.tv.sohu.com'
            info = json.loads(get_content(self.apiurl % self.vid))
            self.logger.debug("info> {}".format(info))

        video = VideoInfo(self.name)
        # this is needless now, uid well be registered in the the following code
        #video.extra["header"] = "Range: "
        if info['status'] == 1:
            now = time.time()
            uid = int(now * 1000)
            params = {
                'vid': self.vid,
                'url': self.url,
                'refer': self.url,
                't': int(now),
                'uid': uid,
                #'nid': nid,
                #'pid': pid,
                #'screen': '1366x768',
                #'channeled': channeled,
                #'MTV_SRC': MTV_SRC,
                #'position': 'page_adbanner',
                #'op': 'click',
                #'details': '{}',
                #'os': 'linux',
                #'platform': 'linux',
                #'passport': '',
            }
            get_content('http://z.m.tv.sohu.com/h5_cc.gif?' + urlencode(params))

            data = info['data']
            video.title = data['tvName']
            for stream in self.supported_stream_types:
                lvid = data.get(stream)
                if lvid == 0 or not lvid:
                    continue
                if lvid != self.vid:
                    _info = json.loads(get_content(self.apiurl % lvid))
                    self.logger.debug("info> {}".format(_info))
                else:
                    _info = info

                self.parser_info(video, _info, stream, lvid, uid)
        return video
Beispiel #22
0
    def prepare(self):
        info = VideoInfo(self.name, True)

        html = get_content(self.url)

        json_stream = match1(html, '"stream": "([a-zA-Z0-9+=/]+)"')
        assert json_stream, 'live video is offline'
        data = json.loads(base64.b64decode(json_stream).decode())
        self.logger.debug('data:\n%s', data)
        assert data['status'] == 200, data['msg']

        room_info = data['data'][0]['gameLiveInfo']
        info.title = '{}「{} - {}」'.format(room_info['roomName'],
                                          room_info['nick'],
                                          room_info['introduction'])
        info.artist = room_info['nick']

        stream_info = random.choice(data['data'][0]['gameStreamInfoList'])
        sUrl = stream_info['sFlvUrl']
        sStreamName = stream_info['sStreamName']
        sUrlSuffix = stream_info['sFlvUrlSuffix']
        sAntiCode = unquote(unescape(stream_info['sFlvAntiCode']))

        params = dict(p.split('=', 1) for p in sAntiCode.split('&') if p)
        params.update({
            'ctype': 'huya_webh5',
            'uid': '0',
            'seqid': str(int(os.urandom(5).hex(), 16)),
            'ver': '1',
            't': '100'  # 102
        })
        fm = base64.b64decode(params['fm']).decode().split('_', 1)[0]
        ss = md5('|'.join([params['seqid'], params['ctype'], params['t']]))

        def link_url(rate):
            if rate:
                streamname = '{}_{}'.format(sStreamName, rate)
            else:
                streamname = sStreamName
            params['wsSecret'] = md5('_'.join(
                [fm, params['uid'], streamname, ss, params['wsTime']]))
            return '{}/{}.{}?{}'.format(sUrl, streamname, sUrlSuffix,
                                        urlencode(params, safe='*'))

        for si in data['vMultiStreamInfo']:
            video_profile = si['sDisplayName']
            stream, _rate = self.profile_2_id_rate(video_profile)
            rate = si['iBitRate'] or _rate
            info.stream_types.append(stream)
            info.streams[stream] = {
                'container': 'flv',
                'video_profile': video_profile,
                'src': [link_url(rate)],
                'size': float('inf')
            }
        return info
Beispiel #23
0
    def prepare(self):
        handlers = [HTTPCookieProcessor()]
        if default_proxy_handler:
            handlers += default_proxy_handler
        install_opener(build_opener(*handlers))
        add_header("Referer", self.url)

        info = VideoInfo(self.name)
        if self.url and not self.vid:
            self.vid = match1(self.url,
                              'https?://www.mgtv.com/b/\d+/(\d+).html')
            if self.vid is None:
                html = get_content(self.url)
                self.vid = match1(html, 'vid=(\d+)', 'vid=\"(\d+)',
                                  'vid: (\d+)')

        did = str(uuid.uuid4())
        tk2 = generate_tk2(did)

        api_info_url = 'https://pcweb.api.mgtv.com/player/video?tk2={}&video_id={}&type=pch5'.format(
            tk2, self.vid)
        meta = json.loads(get_content(api_info_url))

        assert meta['code'] == 200, '[failed] code: {}, msg: {}'.format(
            meta['code'], meta['msg'])
        assert meta['data'], '[Failed] Video info not found.'

        pm2 = meta['data']['atc']['pm2']
        info.title = meta['data']['info']['title']

        api_source_url = 'https://pcweb.api.mgtv.com/player/getSource?pm2={}&tk2={}&video_id={}&type=pch5'.format(
            pm2, tk2, self.vid)
        meta = json.loads(get_content(api_source_url))

        assert meta['code'] == 200, '[failed] code: {}, msg: {}'.format(
            meta['code'], meta['msg'])
        assert meta['data'], '[Failed] Video source not found.'

        data = meta['data']
        domain = data['stream_domain'][0]
        tk2 = generate_tk2(did)
        for lstream in data['stream']:
            lurl = lstream['url']
            if lurl:
                lurl = '{}{}&did={}'.format(domain, lurl, did)
                url = json.loads(get_content(lurl))['info']
                info.streams[self.profile_2_types[lstream['name']]] = {
                    'container': 'm3u8',
                    'video_profile': lstream['name'],
                    'src': [url]
                }
                info.stream_types.append(self.profile_2_types[lstream['name']])
        info.stream_types = sorted(info.stream_types,
                                   key=self.supported_stream_types.index)
        return info
Beispiel #24
0
 def prepare(self):
     info = VideoInfo(self.name)
     self.vid = self.url[-13: -6]
     info.title = self.name + '-' + self.vid
     api_url = 'http://tv.ifeng.com/html5/{}/video.json'.format(self.vid)
     data = json.loads(get_content(api_url)[12:])
     info.stream_types.append('HD')
     info.streams['HD'] = {'container': 'mp4', 'video_profile': u'高清', 'src' : [data['bqSrc']], 'size': 0}
     info.stream_types.append('SD')
     info.streams['SD'] = {'container': 'mp4', 'video_profile': u'高清', 'src' : [data['gqSrc']], 'size': 0}
     return info
Beispiel #25
0
 def build_videoinfo(self, title, artist, size, urls):
     info = VideoInfo(self.name)
     info.title = title
     info.artist = artist
     info.stream_types.append('current')
     info.streams['current'] = {
         'container': 'm3u8',
         'src': urls,
         'size': size
     }
     self.video_info['info'] = info
Beispiel #26
0
    def prepare(self):
        ssl_context = HTTPSHandler(
            context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))
        cookie_handler = HTTPCookieProcessor()
        opener = build_opener(ssl_context, cookie_handler)
        opener.addheaders = [('Cookie','__ysuid=%d' % time.time())]
        install_opener(opener)
        
        info = VideoInfo(self.name)        

        if self.url and not self.vid:
             self.vid = match1(self.url, 'youku\.com/v_show/id_([a-zA-Z0-9=]+)' ,\
                                         'player\.youku\.com/player\.php/sid/([a-zA-Z0-9=]+)/v\.swf',\
                                         'loader\.swf\?VideoIDS=([a-zA-Z0-9=]+)',\
                                         'loader\.swf\?VideoIDS=([a-zA-Z0-9=]+)',\
                                         'player\.youku\.com/embed/([a-zA-Z0-9=]+)',\
                                         'video.tudou.com/v/([a-zA-Z0-9=]+)')

        self.logger.debug("VID: " + self.vid)
        api_url = 'https://ups.youku.com/ups/get.json?vid={}&ccode={}&client_ip=192.168.1.1&utid={}&client_ts={}'.format(self.vid, self.ccode, quote(fetch_cna()), int(time.time()))

        data = json.loads(get_content(api_url))
        assert data['e']['code'] == 0, data['e']['desc']
        data = data['data']
        assert 'stream' in data, data['error']['note']
        info.title = data['video']['title']
        streams = data['stream']
        for s in streams:
            self.logger.debug("stream> " + str(s))
            t = stream_code_to_id[s['stream_type']]
            urls = []
            for u in s['segs']:
                self.logger.debug("seg> " + str(u))
                if u['key'] != -1:
                    if 'cdn_url' in u:
                        urls.append(u['cdn_url'])
                else:
                    self.logger.warning("VIP video, ignore unavailable seg: {}".format(s['segs'].index(u)))
            if len(urls) == 0:
                urls = [s['m3u8_url']]
                c = 'm3u8'
            else:
                c = id_to_container[t]
            size = s['size']
            info.stream_types.append(t)
            info.streams[t] =  {
                    'container': c,
                    'video_profile': stream_code_to_profiles[t],
                    'size': size,
                    'src' : urls
                }
        info.stream_types = sorted(info.stream_types, key = ids.index)
        return info
Beispiel #27
0
 def prepare(self):
     info = VideoInfo(self.name)
     info.live = True
     self.vid = self.url[self.url.rfind('/')+1:].split(".")[0]
     json_request_url = 'http://www.yizhibo.com/live/h5api/get_basic_live_info?scid={}'.format(self.vid)
     content = json.loads(get_content(json_request_url))
     assert content['result'] == 1, "Error : {}".format(content['result'])
     info.title = content['data']['live_title']
     info.artist = content['data']['nickname']
     info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [content['data']['play_url']], 'size': float('inf')}
     info.stream_types.append('current')
     return info
Beispiel #28
0
    def prepare(self):
        info = VideoInfo(self.name)
        html = get_content(self.url)
        info.title, info.artist, sourceVid, m3u8Info = self.get_page_info(html)

        add_header('Referer', 'https://www.acfun.cn/')

        if m3u8Info is None:
            data = json.loads(
                get_content(
                    'https://www.acfun.cn/rest/pc-direct/play/playInfo/m3u8Auto?videoId={}'
                    .format(sourceVid)))
            m3u8Info = data['playInfo']['streams'][0]

        # some videos are broken of CDN, random choose one
        m3u8api = random.choice(m3u8Info['playUrls'])
        self.logger.warning(
            'Request m3u8 info via CDN: %s\nIf video has broken on this CDN, please retry.',
            m3u8api)
        lines = get_content(m3u8api)
        self.logger.debug('m3u8 api: %s', lines)
        lines = lines.split('\n')

        resolutions = None
        for line in lines:
            if resolutions is None:
                resolutions = match1(line, 'RESOLUTION=(\d+x\d+)')
                if resolutions:
                    resolutions = [int(q) for q in resolutions.split('x')]
            elif match1(line, '(\.m3u8)'):
                try:
                    quality = min(resolutions)
                    stream_type = self.quality1_2_id[quality]
                except:
                    quality = max(resolutions)
                    stream_type = self.quality2_2_id[quality]
                resolutions = None
                if line.startswith('http'):
                    url = line
                else:
                    url = urljoin(m3u8api, line)
                stream_profile = self.id_2_profile[stream_type]
                info.stream_types.append(stream_type)
                info.streams[stream_type] = {
                    'container': 'm3u8',
                    'video_profile': stream_profile,
                    'src': [url],
                    'size': 0
                }

        info.stream_types = sorted(info.stream_types,
                                   key=self.stream_ids.index)
        return info
Beispiel #29
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        self.vid = match1(html, '"user_id":"([^"]+)",')
        title = json.loads(match1(html, '"room_name":("[^"]*"),'))
        artist = json.loads(match1(html, '"nick_name":("[^"]+"),'))
        info.title = u'{} - {}'.format(title, artist)
        info.artist = artist

        def get_live_info(rate='source'):
            data = getlive(self.vid, rate)
            self.logger.debug('data:\n' + str(data))
            if data['code'] != 'A00000':
                return data.get('msg')

            data = data['data']
            url = data.get('https_flv') or data.get('flv') or data.get('rtmp')
            if url:
                url = url.replace('rtmp://', 'http://')
                ran = random.randrange(1e4)
                if '?' in url:
                    url = '{}&ran={}'.format(url, ran)
                else:
                    url = '{}?ran={}'.format(url, ran)
                stream_profile = self.rate_2_profile[rate]
                stream_id = self.rate_2_id[rate]
                info.stream_types.append(stream_id)
                info.streams[stream_id] = {
                    'video_profile': stream_profile,
                    'container': 'flv',
                    'src' : [url],
                    'size': float('inf')
                }

            error_msges = []
            if rate == 'source':
                rate_list = data['rate_list']
                if 'source' in rate_list:
                    rate_list.remove('source')
                    for rate in rate_list:
                        error_msg = get_live_info(rate)
                        if error_msg:
                            error_msges.append(error_msg)
            if error_msges:
                return ', '.join(error_msges)

        error_msg = get_live_info()
        if error_msg:
            self.logger.debug('error_msg:\n' + error_msg)
        assert len(info.stream_types), error_msg or 'can\'t play this live video!!'
        info.stream_types = sorted(info.stream_types, key=self.ids.index)

        return info
Beispiel #30
0
    def prepare(self):
        info = VideoInfo(self.name)

        self.vid = match1(self.url, 'play/(\d+)')
        html = get_content(self.url)
        if not self.vid:
            self.vid = match1(html, 'data-vid="(\d+)')
        title = match1(html, '<h1 class="video-title">(.+?)</h1>')
        info.artist = artist = match1(
            html, "<div class='video-author'>[\s\S]+?<h3>(.+?)</h3>")
        info.title = u'{} - {}'.format(title, artist)

        t1 = int(time.time() * 1000)
        t2 = t1 + random.randrange(5, 10)
        rnd = str(random.random()).replace('.', '')
        params = {
            'callback': 'jQuery1124{}_{}'.format(rnd, t1),
            'r': 'vhuyaplay/video',
            'vid': self.vid,
            'format': 'mp4,m3u8',
            '_': t2
        }
        api_url = 'https://v-api-player-ssl.huya.com/?' + urlencode(params)
        data = get_content(api_url)[len(params['callback']) + 1:-1]
        self.logger.debug('data:\n%s', data)

        data = json.loads(data)
        assert data['code'] == 1, data['message']
        data = data['result']['items']

        for stream_date in data:
            ext = stream_date['format']
            quality = min(
                int(q) for q in (stream_date['height'], stream_date['width']))
            stream = self.quality_2_id[quality]
            if stream not in info.stream_types:
                info.stream_types.append(stream)
            elif ext == 'm3u8':
                # prefer mp4
                continue
            video_profile = self.id_2_profile[stream]
            url = stream_date['transcode']['urls'][0]
            info.streams[stream] = {
                'container': ext,
                'video_profile': video_profile,
                'src': [url],
                'size': int(stream_date['size'])
            }

        info.stream_types = sorted(info.stream_types,
                                   key=self.supported_stream_types.index)
        return info
Beispiel #31
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, "anchorCcId : \'([^\']+)")
            info.title = match1(html, "title: \'([^\']+)")
            info.artist = match1(html, "anchorName : \'([^\']+)")

        data = json.loads(get_content("http://cgi.v.cc.163.com/video_play_url/{}".format(self.vid)))

        info.stream_types.append("current")
        info.streams["current"] = {'container': 'flv', 'video_profile': "current", 'src' : [data["videourl"]], 'size': 0}
        return info
Beispiel #32
0
    def prepare(self):
        info = VideoInfo(self.name)
        html = get_content(self.url)
        data = json.loads(match1(html, r'qualities":({.+?}),"'))
        self.title = match1(html, r'"video_title"\s*:\s*"(.+?)",')

        for stream in self.supported_stream_types:
            if stream in info.keys():
                url = data[stream][0]["url"]
                _, ext, size = url_info(url)
                info.stream_types.append(stream)
                info.streams[stream] = {'container': ext, 'src': [url], 'size' : size}
        return info
Beispiel #33
0
    def prepare(self):
        info = VideoInfo(self.name)
        stream_temp = {
            '1080p': None,
            '1300': None,
            '1000': None,
            '720p': None,
            '350': None
        }
        self.__STREAM_TEMP__.append(stream_temp)
        if not self.vid:
            self.vid = match1(self.url, 'vplay/(\d+).html', '#record/(\d+)')

        #normal process
        url = 'http://player-pc.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com&region=cn&source=1000&accesyx=1'.format(
            self.vid, calcTimeKey(int(time.time())))
        r = get_content(url)
        data = json.loads(r)
        data = data['msgs']

        info.title = data['playurl']['title']
        available_stream_id = sorted(list(data["playurl"]["dispatch"].keys()),
                                     key=self.supported_stream_types.index)
        for stream in available_stream_id:
            s_url = data["playurl"]["domain"][0] + data["playurl"]["dispatch"][
                stream][0]
            uuid = hashlib.sha1(s_url.encode('utf8')).hexdigest() + '_0'
            s_url = s_url.replace('tss=0', 'tss=ios')
            s_url += "&m3v=1&termid=1&format=1&hwtype=un&ostype=MacOS10.12.4&p1=1&p2=10&p3=-&expect=3&tn={}&vid={}&uuid={}&sign=letv".format(
                random.random(), self.vid, uuid)
            r2 = get_content(s_url)
            data2 = json.loads(r2)

            # hold on ! more things to do
            # to decode m3u8 (encoded)
            suffix = '&r=' + str(int(time.time() * 1000)) + '&appid=500'
            m3u8 = get_content(data2["location"] + suffix, charset='ignore')
            m3u8_list = decode(m3u8)
            stream_id = self.stream_2_id[stream]
            info.streams[stream_id] = {
                'container': 'm3u8',
                'video_profile': self.stream_2_profile[stream],
                'size': 0
            }
            stream_temp[stream] = compact_tempfile(mode='w+t', suffix='.m3u8')
            stream_temp[stream].write(m3u8_list)
            info.streams[stream_id]['src'] = [stream_temp[stream].name]
            stream_temp[stream].flush()
            info.stream_types.append(stream_id)
        return info
Beispiel #34
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            self.vid = match1(self.url, 'yinyue/(\d+)')

        html = get_content("http://player.kuwo.cn/webmusic/st/getNewMuiseByRid?rid=MUSIC_{}".format(self.vid))
        info.title = match1(html, "<name>(.*)</name>")
        info.artist = match1(html, "<artist>(.*)</artist>")
        for t in self.supported_stream_types:
            url=get_content("http://antiserver.kuwo.cn/anti.s?format={}&rid=MUSIC_{}&type=convert_url&response=url".format(t, self.vid))

            info.stream_types.append(t)
            info.streams[t] = {'container': t, 'video_profile': 'current', 'src' : [url], 'size': 0}
        return info
Beispiel #35
0
    def prepare(self):
        self.vid = match1(self.url, 'd=(\d+)', 'live/(\d+)')
        if '/izt/' in self.url:
            vid = self.vid
            if not vid:
                html = get_content(self.url)
                vid = match1(html, 'vid\s*:\s*"(\d+)",', 'vid="(\d+)"')
            return get_playback(vid)
        else:
            if not self.vid:
                html = get_content(self.url)
                self.vid = match1(html, 'liveId\s*:\s*"(\d+)"')

        live_data = json.loads(
            get_content(
                'http://api.live.letv.com/v1/liveRoom/single/1001?id={}'.
                format(self.vid)))
        if live_data.get('status') != 2:
            return get_playback(live_data['recordingId'])

        # live video is dead, the followed code will not be used
        live_data = json.loads(
            get_content(
                'http://player.pc.le.com/player/startup_by_pid/1001/{}?host=live.le.com'
                .format(self.vid)))

        info = VideoInfo(self.name, True)
        info.title = live_data['title']
        stream_data = live_data['rows']

        for s in stream_data:
            stream_id = self.stream_2_id[s['rateType']]
            stream_profile = self.stream_2_profile[s['rateType']]
            if not stream_id in info.stream_types:
                info.stream_types.append(stream_id)
                streamUrl = s[
                    'streamUrl'] + '&format=1&expect=2&termid=1&platid=10&playid=1&sign=live_web&splatid=1001&vkit=20161017&station={}'.format(
                        self.vid)
                data = json.loads(get_content(streamUrl))
                src = data['location']
                info.streams[stream_id] = {
                    'container': 'm3u8',
                    'video_profile': stream_profile,
                    'size': float('inf'),
                    'src': [src]
                }
        info.stream_types = sorted(info.stream_types,
                                   key=self.stream_ids.index)
        return info
Beispiel #36
0
    def prepare(self):
        info = VideoInfo(self.name)
        add_header('X-Requested-With', 'XMLHttpRequest')
        if self.url:
            self.vid = match1(self.url, 'show/(.*)')

        json_request_url = "https://vmobile.douyu.com/video/getInfo?vid={}".format(self.vid)

        video_data = json.loads(get_content(json_request_url))
        assert video_data['error'] == 0, video_data
        real_url = video_data['data']['video_url']
        info.stream_types.append('current')
        info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [real_url], 'size': 0}
        info.title = self.name + '_' + self.vid
        return info
Beispiel #37
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, 'quanmin.tv/(\w+)')

        content = get_content(self.api_url.format(self.vid))
        stream_data = json.loads(content)
        assert stream_data['status'], u"error: (⊙o⊙)主播暂时不在家,看看其他精彩直播吧!"
        info.title = stream_data["title"]
        info.artist = stream_data['nick']


        info.stream_types.append('current')
        info.streams['current'] = {'container': 'flv', 'video_profile': 'current', 'src' : [self.live_base.format(self.vid)], 'size': float('inf')}
        return info
Beispiel #38
0
 def build_videoinfo(self, title, ext, *urls):
     info = VideoInfo(self.name)
     info.title = title
     channel = 1
     for url in urls:
         t = 'Channel ' + str(channel)
         info.stream_types.append(t)
         info.streams[t] = {
             'container': ext,
             'video_profile': t,
             'src': [url],
             'size' : 0
         }
         channel += 1
     self.video_info['info'] = info
Beispiel #39
0
 def prepare(self):
     info = VideoInfo(self.name, True)
     ID = match1(self.url, "/(\d+)")
     api1_data = json.loads(get_content("https://api.live.bilibili.com/room/v1/Room/room_init?id={}".format(ID)))
     self.vid = api1_data["data"]["room_id"]
     api2_data = json.loads(get_content("https://api.live.bilibili.com/room/v1/Room/get_info?room_id={}&from=room".format(self.vid)))
     info.title = api2_data["data"]["title"]
     for profile in self.supported_stream_profile:
         data = json.loads(get_content("https://api.live.bilibili.com/api/playurl?player=1&cid={}&quality={}&platform=flash&otype=json".format(self.vid, self.supported_stream_profile.index(profile))))
         urls = [data["durl"][0]["url"]]
         size = float('inf')
         ext = 'flv'
         info.stream_types.append(self.profile_2_type[profile])
         info.streams[self.profile_2_type[profile]] = {'container': ext, 'video_profile': profile, 'src' : urls, 'size': size}
     return info
Beispiel #40
0
 def prepare(self):
     info = VideoInfo(self.name)
     html = get_content(self.url)
     metadata = json.loads(match1(html, r'({"talks"(.*)})\)'))
     info.title = metadata['talks'][0]['title']
     nativeDownloads = metadata['talks'][0]['nativeDownloads']
     for quality in self.supported_stream_types:
         if quality in nativeDownloads:
             url = nativeDownloads[quality]
             _, ext, size = url_info(url)
             stream_id = self.types_2_id[quality]
             stream_profile = self.types_2_profile[quality]
             info.streams[stream_id] = {'container': ext, 'video_profile': stream_profile, 'src': [url], 'size' : size}
             info.stream_types.append(stream_id)
     return info
Beispiel #41
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            self.vid = match1(self.url, 'http://music.baidu.com/song/([\d]+)')

        param = urlencode({'songIds': self.vid})

        song_data = json.loads(get_content('http://play.baidu.com/data/music/songlink', data=compact_bytes(param, 'utf-8')))['data']['songList'][0]

        info.title = song_data['songName']
        info.artist = song_data['artistName']

        info.stream_types.append('current')
        info.streams['current'] = {'container': song_data['format'], 'video_profile': 'current', 'src' : [song_data['songLink']], 'size': song_data['size']}
        return info
Beispiel #42
0
    def prepare(self):
        info = VideoInfo(self.name)
        add_header("Referer", "https://www.bilibili.com/")
        info.extra["referer"] = "https://www.bilibili.com/"
        info.extra["ua"] = fake_headers['User-Agent']

        self.vid, info.title, info.artist = self.get_page_info()

        assert self.vid, "can't play this video: {}".format(self.url)

        def get_video_info(qn=0):
            # need login with "qn=112"
            if int(qn) > 80:
                return

            api_url = self.get_api_url(qn)
            html = get_content(api_url)
            self.logger.debug('HTML> ' + html)
            code = match1(html, '<code>([^<])')
            if code:
                return

            urls, size, fmt, qlt, aqlts = parse_cid_playurl(html)
            if 'mp4' in fmt:
                ext = 'mp4'
            elif 'flv' in fmt:
                ext = 'flv'
            st, prf = self.format_2_type_profile[fmt]
            if urls and st not in info.streams:
                info.stream_types.append(st)
                info.streams[st] = {
                    'container': ext,
                    'video_profile': prf,
                    'src': urls,
                    'size': size
                }

            if qn == 0:
                aqlts.remove(qlt)
                for aqlt in aqlts:
                    get_video_info(aqlt)

        get_video_info()

        assert len(info.stream_types), "can't play this video!!"
        info.stream_types = sorted(info.stream_types,
                                   key=self.sorted_format.index)
        return info
Beispiel #43
0
    def parser_list(self, url):
        if "album" in url:
            _id = match1(url, 'http://www.xiami.com/album/(\d+)')
            t = '1'
        elif "collect" in url:
            _id = match1(url, 'http://www.xiami.com/collect/(\d+)')
            t = '3'

        xml = get_content(
            'http://www.xiami.com/song/playlist/id/{}/type/{}'.format(_id, t),
            charset='ignore')
        doc = parseString(xml)
        tracks = doc.getElementsByTagName("trackList")[0]

        info_list = []
        #ugly code TODO
        n = 0
        for t in tracks.getElementsByTagName('track'):
            if not n % 2:
                info = VideoInfo(self.name)
                self.song_data = t
                self.extract_song(info)
                info_list.append(info)
            n += 1
        return info_list
Beispiel #44
0
 def letvcloud_download_by_vu(self):
     info = VideoInfo(self.name)
     #ran = float('0.' + str(random.randint(0, 9999999999999999))) # For ver 2.1
     #str2Hash = 'cfflashformatjsonran{ran}uu{uu}ver2.2vu{vu}bie^#@(%27eib58'.format(vu = vu, uu = uu, ran = ran)  #Magic!/ In ver 2.1
     vu, uu = self.vid
     argumet_dict = {
         'cf': 'flash',
         'format': 'json',
         'ran': str(int(time.time())),
         'uu': str(uu),
         'ver': '2.2',
         'vu': str(vu),
     }
     sign_key = '2f9d6924b33a165a6d8b5d3d42f4f987'  #ALL YOUR BASE ARE BELONG TO US
     str2Hash = ''.join([i + argumet_dict[i]
                         for i in sorted(argumet_dict)]) + sign_key
     sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
     html = get_content(
         'http://api.letvcloud.com/gpc.php?' +
         '&'.join([i + '=' + argumet_dict[i] for i in argumet_dict]) +
         '&sign={sign}'.format(sign=sign),
         charset='utf-8')
     data = json.loads(html)
     assert data['code'] == 0, data['message']
     video_name = data['data']['video_info']['video_name']
     if '.' in video_name:
         ext = video_name.split('.')[-1]
         info.title = video_name[0:-len(ext) - 1]
     else:
         ext = 'mp4'
         info.title = video_name
     available_stream_type = data['data']['video_info']['media'].keys()
     for stream in self.supported_stream_types:
         if stream in available_stream_type:
             urls = [
                 base64.b64decode(
                     data['data']['video_info']['media'][stream]['play_url']
                     ['main_url']).decode("utf-8")
             ]
             info.stream_types.append(stream)
             info.streams[stream] = {
                 'container': ext,
                 'video_profile': stream,
                 'src': urls,
                 'size': 0
             }
     return info
Beispiel #45
0
    def prepare(self):
        assert self.url, "please provide valid url"
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        Alias = match1(html, 'initAlias:\'([^\']+)' ,'"ln":\s*"([^"]+)"')
        Token = match1(html, 'initToken: \'([^\']+)', '"tk":\s*"([^"]+)"')
        info.artist = match1(html, 'anchorName:\s*\'([^\']+)', '"anchorName":\s*"([^"]+)"')
        info.title = info.artist + u'的直播房间'
        t = datetime.datetime.utcnow().isoformat().split('.')[0] + 'Z'
        api_url = "http://lapi.lcloud.laifeng.com/Play?AppId=101&StreamName={}&Action=Schedule&Token={}&Version=2.0&CallerVersion=3.3&Caller=flash&Format=HttpFlv&Timestamp={}&Format=HttpFlv&rd={}".format(Alias, Token, t, randint(10000, 99999) )
        data1 = json.loads(get_content(api_url))
        assert data1['Code'] == 'Success', data1['Message']
        stream_url = data1['HttpFlv'][0]['Url']

        info.stream_types.append('current')
        info.streams['current'] = {'container': 'flv', 'video_profile': 'current', 'src' : [stream_url], 'size': float('inf')}
        return info
Beispiel #46
0
    def prepare(self):
        info = VideoInfo(self.name)
        stream_temp = {
            '1080p': None,
            '1300': None,
            '1000': None,
            '720p': None,
            '350': None
        }
        self.__STREAM_TEMP__.append(stream_temp)
        if not self.vid:
            self.vid = match1(self.url, 'vplay/(\d+).html', '#record/(\d+)')

        #normal process
        info_url = 'http://api.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com'.format(
            self.vid, calcTimeKey(int(time.time())))
        r = get_content(info_url)
        data = json.loads(r)

        info.title = data['playurl']['title']
        available_stream_id = sorted(list(data["playurl"]["dispatch"].keys()),
                                     key=self.supported_stream_types.index)
        for stream in available_stream_id:
            s_url = data["playurl"]["domain"][0] + data["playurl"]["dispatch"][
                stream][0]
            s_url += "&ctv=pc&m3v=1&termid=1&format=1&hwtype=un&ostype=Linux&tag=le&sign=le&expect=3&tn={}&pay=0&iscpn=f9051&rateid={}".format(
                random.random(), stream)
            r2 = get_content(s_url)
            data2 = json.loads(r2)

            # hold on ! more things to do
            # to decode m3u8 (encoded)
            m3u8 = get_content(data2["location"], charset='ignore')
            m3u8_list = decode(m3u8)
            stream_id = self.stream_2_id[stream]
            info.streams[stream_id] = {
                'container': 'm3u8',
                'video_profile': self.stream_2_profile[stream],
                'size': 0
            }
            stream_temp[stream] = compact_tempfile(mode='w+t', suffix='.m3u8')
            stream_temp[stream].write(m3u8_list)
            info.streams[stream_id]['src'] = [stream_temp[stream].name]
            stream_temp[stream].flush()
            info.stream_types.append(stream_id)
        return info
Beispiel #47
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            self.vid= match1(self.url, '#([a-zA-Z0-9\-]+)', '/([a-zA-Z0-9\-]+).shtml')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"vid": "([^"]+)', 'vid: "([^"]+)')

        xml = get_content('http://vxml.ifengimg.com/video_info_new/{}/{}/{}.xml'.format(self.vid[-2], self.vid[-2:], self.vid))

        info.title = match1(xml, 'SE_Title="([^"]+)')
        urls = matchall(xml, ['playurl="([^"]+)'])
        urls = ['http://ips.ifeng.com/' + u[7:] for u in urls ]
        info.stream_types.append('current')
        info.streams['current'] = {'container': 'mp4', 'video_profile': 'current', 'src' : urls, 'size': 0}

        return info
Beispiel #48
0
    def prepare(self):
        add_header("Referer", "http://music.163.com/")
        video = VideoInfo(self.name)
        if not self.vid:
            self.vid =  match1(self.url, 'id=(.*)')

        api_url = "http://music.163.com/api/mv/detail/?id={}&ids=[{}]&csrf_token=".format(self.vid, self.vid)
        mv = json.loads(get_content(api_url))['data']
        video.title = mv['name']
        video.artist = mv['artistName']
        for code in self.supported_stream_code:
            if code in mv['brs']:
                stream_id = self.code_2_id[code]
                stream_profile = self.code_2_profile[code]
                video.stream_types.append(stream_id)
                video.streams[stream_id] = {'container': 'mp4', 'video_profile': stream_profile, 'src' : [mv['brs'][code]], 'size': 0}
        return video
Beispiel #49
0
    def prepare(self):
        info = VideoInfo(self.name)
        self.vid, self.embsig = self.vid

        api = "http://aauth-vod.cn-beijing.aliyuncs.com/acfun/web?vid={}&ct={}&time={}&sign={}&ev=3".format(self.vid, self.ct,int(time.time()*1000), self.embsig)
        data = rc4(self.key, base64.b64decode(json.loads(get_content(api, charset='utf-8'))['data']))
        stream_data = json.loads(data)
        info.title = stream_data['video']['title']
        for s in stream_data['stream']:
            if 'segs' in s:
                stream_type = stream_code_to_id[s['stream_type']]
                stream_urls = [seg['url'] for seg in s['segs']]
                size = s['total_size']
                info.stream_types.append(stream_type)
                info.streams[stream_type] = {'container': 'mp4', 'video_profile': stream_code_to_profiles[stream_type], 'src': stream_urls, 'size' : size}
        info.stream_types = sorted(info.stream_types, key=ids.index)
        return info
Beispiel #50
0
    def prepare(self):
        info = VideoInfo(self.name)
        if self.url and not self.vid:
            vid = matchall(self.url, ['curid=([^_]+)_([\w]+)'])
            if vid:
                self.vid = vid[0]
                info_u = 'http://mixer.video.iqiyi.com/jp/mixin/videos/' + self.vid[
                    0]
                mixin = get_content(info_u)
                mixin_json = json.loads(mixin[len('var tvInfoJs='):])
                real_u = mixin_json['url']
                real_html = get_content(real_u)
                info.title = match1(real_html, '<title>([^<]+)').split('-')[0]

        if self.url and not self.vid:
            html = get_content(self.url)
            video_info = match1(html, ":video-info='(.+?)'")
            if video_info:
                video_info = json.loads(video_info)
                self.vid = str(video_info['tvId']), str(video_info['vid'])
                info.title = video_info['name']
            else:

                tvid = match1(html, 'data-player-tvid="([^"]+)"',
                              'tvid="(.+?)"', 'tvId:([^,]+)',
                              r'''param\['tvid'\]\s*=\s*"(.+?)"''',
                              r'"tvid":\s*"(\d+)"')
                videoid = match1(html, 'data-player-videoid="([^"]+)"',
                                 'vid="(.+?)"', 'vid:"([^"]+)',
                                 r'''param\['vid'\]\s*=\s*"(.+?)"''',
                                 r'"vid":\s*"(\w+)"')
                self.vid = (tvid, videoid)
                info.title = match1(html, '<title>([^<]+)').split('-')[0]

        tvid, vid = self.vid
        vps_data = getvps(tvid, vid)
        assert vps_data['code'] == 'A00000', 'can\'t play this video!!'
        url_prefix = vps_data['data']['vp']['du']
        stream = vps_data['data']['vp']['tkl'][0]
        vs_array = stream['vs']
        for vs in vs_array:
            bid = vs['bid']
            fs_array = vs['fs']
            real_urls = []
            for seg_info in fs_array:
                url = url_prefix + seg_info['l']
                json_data = json.loads(get_content(url))
                down_url = json_data['l']
                real_urls.append(down_url)
            stream = self.vd_2_id[bid]
            info.stream_types.append(stream)
            stream_profile = self.id_2_profile[stream]
            info.streams[stream] = {
                'video_profile': stream_profile,
                'container': 'flv',
                'src': real_urls,
                'size': 0
            }
        info.stream_types = sorted(info.stream_types, key=self.ids.index)
        return info
Beispiel #51
0
    def prepare(self):
        info = VideoInfo(self.name)

        vid = match1(self.url, '/(\d+)\.mp4')
        if vid:
            r_url = get_location(
                'https://ask.ivideo.sina.com.cn/v_play_ipad.php?vid=' + vid)
        elif 'vid=' in self.url:
            r_url = get_location(self.url)

        info.stream_types.append('current')
        info.streams['current'] = {
            'container': 'mp4',
            'video_profile': 'current',
            'src': [r_url],
            'size': 0
        }
        return info
Beispiel #52
0
    def prepare(self):
        add_default_handler(HTTPCookieProcessor)
        install_default_handlers()
        add_header('Referer', self.url)
        add_header('User-Agent', ua)

        info = VideoInfo(self.name)
        if self.url and not self.vid:
            self.vid = match1(self.url,
                              'https?://(?:www.)?mgtv.com/b/\d+/(\d+).html')
            if self.vid is None:
                html = get_content(self.url)
                self.vid = match1(html, 'vid=(\d+)', 'vid=\"(\d+)',
                                  'vid: (\d+)')

        did = str(uuid.uuid4())
        tk2 = generate_tk2(did)

        api_info_url = 'https://pcweb.api.mgtv.com/player/video?tk2={}&video_id={}&type=pch5'.format(
            tk2, self.vid)
        meta = json.loads(get_content(api_info_url))
        self.logger.debug('meta >\n%s', meta)

        assert meta['code'] == 200, '[failed] code: {}, msg: {}'.format(
            meta['code'], meta['msg'])
        assert meta['data'], '[Failed] Video info not found.'

        pm2 = meta['data']['atc']['pm2']
        info.title = meta['data']['info']['title'] + ' ' + meta['data'][
            'info']['desc']

        api_source_url = 'https://pcweb.api.mgtv.com/player/getSource?pm2={}&tk2={}&video_id={}&type=pch5'.format(
            pm2, tk2, self.vid)
        meta = json.loads(get_content(api_source_url))

        assert meta['code'] == 200, '[failed] code: {}, msg: {}'.format(
            meta['code'], meta['msg'])
        assert meta['data'], '[Failed] Video source not found.'

        data = meta['data']
        domain = data['stream_domain'][0]
        for lstream in data['stream']:
            lurl = lstream['url']
            if lurl:
                lurl = '{}{}&did={}'.format(domain, lurl, did)
                url = json.loads(get_content(lurl))['info']
                video_profile = lstream['name']
                stream = self.profile_2_types[video_profile]
                info.streams[stream] = {
                    'container': 'm3u8',
                    'video_profile': video_profile,
                    'src': [url]
                }
                info.stream_types.append(stream)
        info.stream_types = sorted(info.stream_types,
                                   key=self.supported_stream_types.index)
        info.extra['referer'] = self.url
        info.extra['ua'] = ua
        return info
Beispiel #53
0
    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, '/(\d+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"room_id":(\d+)')

        #from upstream!!
        api_url = 'http://www.qie.tv/api/v1/room/{}'.format(self.vid)

        metadata = json.loads(get_content(api_url))
        assert metadata['error'] == 0, 'error {}: {}'.format(
            metadata['error'], metadata['data'])

        livedata = metadata['data']
        assert livedata[
            'show_status'] == '1', 'error: live show is not on line!!'

        info.title = livedata['room_name']
        info.artist = livedata['nickname']

        base_url = livedata['rtmp_url']

        if 'hls_url' in livedata:
            info.stream_types.append('BD')
            info.streams['BD'] = {
                'container': 'm3u8',
                'video_profile': u'原画',
                'src': [livedata['hls_url']],
                'size': float('inf')
            }

        mutli_stream = livedata['rtmp_multi_bitrate']
        for i in self.mutli_bitrate:
            if i in mutli_stream:
                info.stream_types.append(self.bitrate_2_type[i])
                info.streams[self.bitrate_2_type[i]] = {
                    'container': 'flv',
                    'video_profile': self.bitrate_2_profile[i],
                    'src': [base_url + '/' + mutli_stream[i]],
                    'size': float('inf')
                }
        return info
Beispiel #54
0
    def prepare(self):
        info = VideoInfo(self.name)
        add_header("Referer", "http://www.bilibili.com")
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 'cid=(\d+)', 'cid=\"(\d+)')
            info.title = match1(html, '<title>([^<]+)').split("_")[0].strip(
                u" 番剧 bilibili 哔哩哔哩弹幕视频网")
            if not self.vid:
                eid = match1(self.url, 'anime/v/(\d+)',
                             'play#(\d+)') or match1(html, 'anime/v/(\d+)')
                if eid:
                    Episode_info = json.loads(
                        get_content(
                            'http://bangumi.bilibili.com/web_api/episode/{}.json'
                            .format(eid)))['result']['currentEpisode']
                    self.vid = Episode_info['danmaku']
                    info.title = info.title + ' ' + Episode_info[
                        'index'] + '.  ' + Episode_info['longTitle']

        assert self.vid, "can't play this video: {}".format(self.url)
        for q in self.supported_stream_profile:
            sign_this = hashlib.md5(
                compact_bytes(
                    'cid={}&from=miniplay&player=1&quality={}{}'.format(
                        self.vid, 3 - self.supported_stream_profile.index(q),
                        SECRETKEY_MINILOADER), 'utf-8')).hexdigest()
            api_url = 'http://interface.bilibili.com/playurl?cid={}&player=1&quality={}&from=miniplay&sign={}'.format(
                self.vid, 3 - self.supported_stream_profile.index(q),
                sign_this)
            html = get_content(api_url)
            self.logger.debug("HTML> {}".format(html))
            urls, size, ext = parse_cid_playurl(html)
            if ext == 'hdmp4':
                ext = 'mp4'

            info.stream_types.append(self.profile_2_type[q])
            info.streams[self.profile_2_type[q]] = {
                'container': ext,
                'video_profile': q,
                'src': urls,
                'size': size
            }
        return info
Beispiel #55
0
    def prepare(self):
        info = VideoInfo(self.name)
        add_header("Referer", "http://music.163.com/")
        if not self.vid:
            self.vid = match1(self.url, 'song/(\d+)', '\?id=(.*)')
        api_url = self.api_url.format(self.vid, self.vid)
        music = self.get_music(json.loads(get_content(api_url)))

        info.title = music['name']
        info.artist = music['artists'][0]['name']

        self.mp3_host = music['mp3Url'][8]

        for st in self.supported_stream_types:
            if st in music and music[st]:
                info.stream_types.append(st)
                self.song_date[st] = music[st]
                self.extract_song(info)
        return info
Beispiel #56
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.url:
            self.url = 'instagram.com/p/{}'.format(self.vid)

        if not self.vid:
            self.vid = match1(self.url, 'instagram.com/p/([^/]+)')

        html = get_content(self.url)
        info.title = match1(html,
                            '<meta property="og:title" content="([^"]*)"')
        stream = match1(html, '<meta property="og:video" content="([^"]*)"')
        mime, ext, size = url_info(stream)
        info.streams['current'] = {
            'container': ext,
            'src': [stream],
            'size': size
        }
        info.stream_types.append('current')
Beispiel #57
0
    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            self.vid = match1(self.url, 'vid=(\w+)')

        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 'vid:\s*\"([^\"]+)', 'vid\s*=\s*"\s*([^"]+)"', 'vid=(\w+)')

        for stream in self.supported_stream_types:
            title, fmt_name, type_name, urls, size = self.get_stream_info(stream)
            stream_id = self.stream_2_id[fmt_name]
            stream_profile = self.stream_2_profile[fmt_name]
            if not stream_id in info.stream_types:
                info.stream_types.append(stream_id)
                info.streams[stream_id] = {'container': type_name, 'video_profile': stream_profile, 'src' : urls, 'size': size}
        info.stream_types = sorted(info.stream_types, key = self.stream_ids.index)
        info.title = title
        return info