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
def prepare(self): info = VideoInfo(self.name) html = get_content(self.url) info.title = match1(html, '<meta property="og:title" content="([^"]+)', '<title>(.+?)</title>') url = match1(html, pattern) or match1(unquote(unescape(html)), pattern) if url: url = json.loads('"{url}"'.format(**vars())) url = match1(url, '.+(https?://.+)') or url # redirect clear if url[0] == '/': url = self.url[:self.url.find('/')] + url ext = url_info(url)[1] if ext[:3] == 'm3u': info.stream_types, info.streams = load_m3u8_playlist(url) else: info.stream_types.append('current') info.streams['current'] = { 'container': ext, 'video_profile': 'current', 'src': [url], 'size': 0 } self.info = info self.parser = self.pparser return info
def get_info(self): size = 0 ext = '' for u in self.v_url: _, ext, temp = url_info(u) size += temp return ext, size
def get_info(self): size=0 ext='' for u in self.v_url: _, ext, temp = url_info(u) size += temp return ext, size
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 extract(self): if self.param.info: for stream_id in self.streams.keys(): size = 0 for i in self.streams[stream_id]['src']: _, _, tmp = url_info(i) size += tmp self.streams[stream_id]['size'] = size return #ignore video size in download/play mode, for preformence issue stream_id = self.param.format or self.stream_types[0] size = 0 for i in self.streams[stream_id]['src']: _, _, tmp = url_info(i) size += tmp self.streams[stream_id]['size'] = size
def extract(self): if self.param.info: for stream_id in self.streams.keys(): size = 0 for i in self.streams[stream_id]['src']: _, _, tmp = url_info(i) size += tmp self.streams[stream_id]['size'] = size return #ignore video size in download/play mode, for preformence issue stream_id = self.param.format or self.stream_types[0] size = 0 for i in self.streams[stream_id]['src']: _, _, tmp = url_info(i) size += tmp self.streams[stream_id]['size'] = size
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): 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
def prepare(self): info = VideoInfo(self.name) if not self.vid: self.vid = match1(self.url, 'resourceId=([0-9]+)') if not self.url: self.url = "http://www.joy.cn/video?resourceId={}".format(self.vid) html= get_content(self.url) info.title = match1(html, '<meta content=\"([^\"]+)') url = matchall(html, ['<source src=\"([^\"]+)'])[3] _, ext, size = url_info(url) info.stream_types.append('current') info.streams['current'] = {'container': ext, 'src': [url], 'size': size } return info
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')
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
def prepare(self): info = VideoInfo(self.name) if not self.vid: self.vid = match1(self.url, 'resourceId=([0-9]+)') if not self.url: self.url = "http://www.joy.cn/video?resourceId={}".format(self.vid) html = get_content(self.url) info.title = match1(html, '<meta content=\"([^\"]+)') url = matchall(html, '<source src=\"([^\"]+)')[3] _, ext, size = url_info(url) info.stream_types.append('current') info.streams['current'] = { 'container': ext, 'src': [url], 'size': size } return info
def prepare(self): info = VideoInfo(self.name) html = None title = None if 'show' in self.url: new_url = get_location(self.url) if new_url != self.url: self.logger.debug('redirect to' + new_url) self.url = new_url if not self.vid: self.vid = match1(self.url, '/media/([^\./]+)') if not self.vid: html = get_content(self.url) self.vid = match1(html, 's[cm]id ?= ?[\'"]([^\'"]+)[\'"]') assert self.vid, "No VID match!" info.title = self.name + '_' + self.vid if len(self.vid) > 24: add_header('Referer', self.url) cb = '_jsonp{}'.format(get_random_str(10)) json_html = get_content(api_info1.format(self.vid, cb)) data = json.loads(json_html[json_html.find('{'):-2]) assert data['code'] == 200, data['msg'] data = data['data'] title = data['description'] url = data['meta_data'][0]['play_urls']['m'] _, ext, _ = url_info(url) else: try: data = json.loads(get_content(api_info2.format(self.vid))) assert data['status'] == 200, data['msg'] data = data['result'] title = data['ext']['t'] scid = data['scid'] or self.vid ext = data['stream']['and'] base = data['stream']['base'] vend = data['stream']['vend'] url = '{}{}.{}?vend={}'.format(base, scid, ext, vend) except: # fallback data = json.loads(get_content(api_stream.format(self.vid))) assert data['status'] == 200, data['msg'] data = data['result'][0] ext = None scheme = data['scheme'] host = data['host'] path = data['path'] sign = data['sign'] url = '{}{}{}{}'.format(scheme, host, path, sign) if not title: if not html: html = get_content(self.url) title = match1(html, '<meta name="description" content="([^"]+)">') if title: info.title = title info.stream_types.append('current') info.streams['current'] = { 'container': ext or 'mp4', 'src': [url], 'size' : 0 } return info