def prepare(self): info = VideoInfo(self.name, True) html = get_content(self.url) t_a = match1(html, '"keywords" content="([^"]+)') info.title = t_a.split(',')[0] info.artist = t_a.split(',')[1] replay_url = match1(html, '"m3u8":"([^"]+)') if replay_url: replay_url = replay_url.replace('\/','/') info.live = False info.stream_types.append('current') info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [replay_url], 'size': float('inf')} return info self.vid = match1(html, '"sn":"([^"]+)') channel = match1(html, '"channel":"([^"]+)') api_url = 'http://g2.live.360.cn/liveplay?stype=flv&channel={}&bid=huajiao&sn={}&sid={}&_rate=xd&ts={}&r={}&_ostype=flash&_delay=0&_sign=null&_ver=13'.format(channel, self.vid, SID, time.time(),random.random()) encoded_json = get_content(api_url) decoded_json = base64.decodestring(compact_bytes(encoded_json[0:3]+ encoded_json[6:], 'utf-8')).decode('utf-8') video_data = json.loads(decoded_json) live_url = video_data['main'] info.live = True info.stream_types.append('current') info.streams['current'] = {'container': 'flv', 'video_profile': 'current', 'src' : [live_url], 'size': float('inf')} return info
def prepare_list(self): html = get_content(self.url) sid = match1(html, 'var season_id = "(\d+)";') or match1(self.url, "anime/(\d+)") j_ = get_content("https://bangumi.bilibili.com/jsonp/seasoninfo/{}.ver?callback=seasonListCallback".format(sid))[19:-2] s_data = json.loads(j_) urls = [e['webplay_url'] for e in sorted(s_data['result']['episodes'], key=lambda e: int(e['index']))] return urls
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
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
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
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
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
def l_assert(self): # Mobile ver. self.title_patterns = '"content2": "(.+?)",', '"status_title": "(.+?)",' self.url_patterns = '"stream_url_hd": "([^"]+)', '"stream_url": "([^"]+)' if 'm.weibo.cn' in self.url: return if 'weibo.com' in self.url and '/tv/v/' not in self.url and 'fid=' not in self.url: self.url = self.url.replace('weibo.com', 'm.weibo.cn', 1) return self.url_patterns = r'(?:data-url|controls src)\s*=\s*[\"\']([^\"\']+)', self.title_patterns = '<title>([^<]+)</', self.url = self.url.replace('%3A', ':') fid = match1(self.url, r'\?fid=(\d{4}:\w+)') if fid is not None: self.url = 'http://p.weibo.com/show/channerWbH5/{}'.format(fid) elif '/p/230444' in self.url: fid = match1(url, r'/p/230444(\w+)') self.url = 'http://p.weibo.com/show/channerWbH5/1034:{}'.format(fid) else: html = get_content(self.url) url = match1(html, '"page_url": "([^"]+)') assert url, 'No url match' self.url = url self.l_assert()
def prepare(self): html = get_content(self.url) title = match1(html, u'<title>(.+?)丨嘀哩嘀哩</title>') source_url = match1(html, r'var sourceUrl\s?=\s?"(.+?)"', r'var Url\s?=\s?"(.+?)"') # First type, bangumi # http://www.dilidili.wang/watch3/72766/ or # http://www.dilidili.wang/watch3/52919/ if source_url: ext = source_url.split('?')[0].split('.')[-1] # Dilidili hosts this video itself if ext in ('mp4', 'flv', 'f4v', 'm3u', 'm3u8'): self.build_videoinfo(title, ext, source_url) # It is an embedded video from other websites else: self.video_info['url'] = source_url self.video_info['title'] = title # Second type, user-uploaded videos # http://www.dilidili.wang/huiyuan/76983/ else: player_url = match1(html, r'<iframe src="(.+?)"') html = get_content(player_url) video_url = match1(html, r'var main = "(.+?)"') video_url_full = '/'.join(player_url.split('/')[0:3]) + video_url ext = video_url.split('?')[0].split('.')[-1] self.build_videoinfo(title, ext, video_url_full)
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
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
def prepare(self): assert self.url, "please provide valid url" info = VideoInfo(self.name, True) html = get_content(self.url) Alias = match1(html, 'initAlias:\'([^\']+)') Token = match1(html, 'initToken: \'([^\']+)') info.artist = match1(html, 'anchorName:\'([^\']+)') info.title = info.artist + u'的直播房间' api_url = "http://lapi.xiu.youku.com/v1/get_playlist?app_id=101&alias={}&token={}&player_type=flash&sdkversion=0.1.0&playerversion=3.1.0&rd={}".format( Alias, Token, randint(0, 9999)) data1 = json.loads(get_content(api_url)) assert data1['error_code'] == 0 url_data = data1['url_list'][0] stream_url = json.loads(get_content(url_data['url']))['u'] info.stream_types.append('current') info.streams['current'] = { 'container': url_data["format"], 'video_profile': 'current', 'src': [stream_url], 'size': float('inf') } return info
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) data = json.loads(get_content(api_url)) self.logger.debug('data:\n%s', data) assert data['error'] == 0, 'error {}: {}'.format( data['error'], data['data']) livedata = data['data'] assert livedata[ 'show_status'] == '1', 'error: live show is not on line!!' info.title = livedata['room_name'] info.artist = livedata['nickname'] info.stream_types.append('current') info.streams['current'] = { 'container': 'flv', 'video_profile': 'current', 'src': ['{}/{}'.format(livedata['rtmp_url'], livedata['rtmp_live'])], 'size': float('inf') } return info
def get_vid(url): vid = match1(url, 'http://www.mgtv.com/b/\d+/(\d+).html') if vid is None: html = get_content(url) vid = match1(html, 'vid=(\d+)', 'vid=\"(\d+)') or \ match1(html, r'vid: (\d+)') return vid
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
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
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
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
def get_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, 'tvId:\s*"([^"]+)', 'data-video-tvId="([^"]+)', '''\['tvid'\]\s*=\s*"([^"]+)''', '"tvId":\s*([^,]+)') videoid = match1(html, 'data-video-vid="([^"]+)', 'vid:\s*"([^"]+)', '''\['vid'\]\s*=\s*"([^"]+)''', '"vid":\s*([^,]+)') if not (tvid and videoid): url = match1(html, '(www\.iqiyi\.com/v_\w+\.html)') if url: self.url = 'https://' + url return get_vid() self.vid = (tvid, videoid) info.title = match1(html, '<title>([^<]+)').split('-')[0]
def get_vid_title(self): html = get_content(self.url) title = match1(html, '<h1 title="([^"]+)', '<title>([^<]+)').strip() vid = match1(html, '"loaded":true[^\{]+?"cid":(\d+)', '"cid":(\d+)', 'cid=(\d+)', 'cid="(\d+)') self.seasonType = match1(html, '"season_type":(\d+)', '"ssType":(\d+)') return vid, title
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
def prepare(self): self.live = True if not self.vid: html = get_content(self.url) self.vid = match1(html, "anchorCcId : \'([^\']+)") self.title = match1(html, "title: \'([^\']+)") self.artist = match1(html, "anchorName : \'([^\']+)") info = json.loads(get_content("http://cgi.v.cc.163.com/video_play_url/{}".format(self.vid))) self.stream_types.append("current") self.streams["current"] = {'container': 'flv', 'video_profile': "current", 'src' : [info["videourl"]], 'size': 0}
def prepare(self): 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)) self.title = match1(html, "<name>(.*)</name>") self.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)) self.stream_types.append(t) self.streams[t] = {'container': t, 'video_profile': 'current', 'src' : [url], 'size': 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
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
def prepare(self): if not self.vid: html = get_content(self.url) self.vid = match1(html, 'cid=([^&]+)') self.title = match1(html, '<title>([^<]+)').split("_")[0] for q in self.supported_stream_profile: api_url = 'http://interface.bilibili.com/playurl?appkey=' + appkey + '&cid=' + self.vid + '&quality=' + str(3-self.supported_stream_profile.index(q)) urls, size = parse_cid_playurl(get_content(api_url)) ext = 'flv' self.stream_types.append(self.profile_2_type[q]) self.streams[self.profile_2_type[q]] = {'container': ext, 'video_profile': q, 'src' : urls, 'size': size}
def prepare(self): info = VideoInfo(self.name, True) if not self.vid: html = get_content(self.url) self.vid = match1(html, "anchorCcId\s*:\s*\'([^\']+)") info.title = match1(html, "title:\s*\'([^\']+)") info.artist = match1(html, "anchorName\s*:\s*\'([^\']+)") 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
def prepare(self): info = VideoInfo(self.name) if not self.vid: self.vid = match1(self.url, 'http://www.xiami.com/song/(\d+)', 'http://www.xiami.com/song/detail/id/(\d+)') if not self.vid or len(self.vid) < 10: html = get_content(self.url) line = match1(html, '(.*)立即播放</a>') self.vid = match1(line, 'play\(\'(\d+)') xml = get_content('http://www.xiami.com/song/playlist/id/{}/object_name/default/object_id/0'.format(self.vid) , charset = 'ignore') doc = parseString(xml) self.song_data = doc.getElementsByTagName("track")[0] self.extract_song(info) return info
def prepare(self): if not self.vid: self.vid = match1(self.url, 'vid=(\w+)') if not self.vid: html = get_content(self.url) match1(html, 'vid:\"([^\"]+)') for stream in self.supported_stream_types: fmt_name, type_name, urls, size = self.get_stream_info(stream) self.streams[fmt_name] = {'container': type_name, 'video_profile': self.stream_2_profile[fmt_name], 'src' : urls, 'size': size} if not fmt_name in self.stream_types: self.stream_types.append(fmt_name) self.stream_types = sorted(self.stream_types, key = self.supported_stream_types.index)
def prepare(self): info = VideoInfo(self.name) if not self.vid: self.vid = match1(self.url, 'vid=(\w+)', '/(\w+)\.html') if self.vid and match1(self.url, '(^https?://film\.qq\.com)'): self.url = 'http://v.qq.com/x/cover/%s.html' % self.vid if not self.vid or len(self.vid) != 11: html = get_content(self.url) self.vid = match1(html, '&vid=(\w+)', 'vid:\s*[\"\'](\w+)', 'vid\s*=\s*[\"\']\s*(\w+)') if not self.vid and '<body class="page_404">' in html: self.logger.warning('This video has been deleted!') return info video_rate = {} for _ in range(2): try: for title, fmt_name, stream_profile, type_name, urls, size, rate in self.get_streams_info(): stream_id = self.stream_2_id[fmt_name] if urls and stream_id not 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} video_rate[stream_id] = rate break except AssertionError as e: if 'wrong vid' in str(e): html = get_content(self.url) self.vid = match1(html, '&vid=(\w+)', 'vid:\s*[\"\'](\w+)', 'vid\s*=\s*[\"\']\s*(\w+)') continue raise e if self.vip: self.logger.warning('This is a VIP video!') self.slow = False assert len(info.stream_types), "can't play this video!!" info.stream_types = sorted(info.stream_types, key = self.stream_ids.index) info.title = title if self.slow: # Downloading some videos is very slow, use multithreading range fetch to speed up. # Only for video players now. info.extra['rangefetch'] = {'first_size': 1024 * 16, 'max_size': 1024 * 32, 'threads': 10, 'video_rate': video_rate} self.logger.warning('This is a slow video!') return info
def prepare(self): if not self.vid: self.vid = match1(self.url, 'http://www.xiami.com/song/(\d+)', 'http://www.xiami.com/song/detail/id/(\d+)') xml = get_content('http://www.xiami.com/song/playlist/id/{}/object_name/default/object_id/0'.format(self.vid) , charset = 'ignore') doc = parseString(xml) self.song_data = doc.getElementsByTagName("track")[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
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