本文整理汇总了Python中ykdl.videoinfo.VideoInfo.streams[stream_id]方法的典型用法代码示例。如果您正苦于以下问题:Python VideoInfo.streams[stream_id]方法的具体用法?Python VideoInfo.streams[stream_id]怎么用?Python VideoInfo.streams[stream_id]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ykdl.videoinfo.VideoInfo
的用法示例。
在下文中一共展示了VideoInfo.streams[stream_id]方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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
示例2: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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
示例3: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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
示例4: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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
示例5: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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
示例6: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
def prepare(self):
add_header("Referer", "http://music.163.com/")
video = VideoInfo(self.name)
if not self.vid:
self.vid = match1(self.url, '\?id=(.*)', 'mv/(\d+)')
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
示例7: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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:\"([^\"]+)')
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
示例8: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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')
xml = get_content('http://v.ifeng.com/video_info_new/{}/{}/{}.xml'.format(self.vid[-2], self.vid[-2:], self.vid))
doc = parseString(xml.encode('utf-8'))
info.title = doc.getElementsByTagName('item')[0].getAttribute("Name")
videos = doc.getElementsByTagName('videos')
for v in videos[0].getElementsByTagName('video'):
if v.getAttribute("mediaType") == 'mp4':
_t = v.getAttribute("type")
_u = v.getAttribute("VideoPlayUrl")
stream_id = self.types_2_id[_t]
stream_profile = self.types_2_profile[_t]
info.stream_types.append(stream_id)
info.streams[stream_id] = {'container': 'mp4', 'video_profile': stream_profile, 'src' : [_u], 'size': 0}
info.stream_types = sorted(info.stream_types, key = self.ids.index)
return info
示例9: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
def prepare(self):
info = VideoInfo(self.name)
if not self.vid:
self.vid = match1(self.url, 'http://\w+.yinyuetai.com/video/(\d+)')
data = json.loads(get_content('http://ext.yinyuetai.com/main/get-h-mv-info?json=true&videoId={}'.format(self.vid)))
assert not data['error'], 'some error happens'
video_data = data['videoInfo']['coreVideoInfo']
info.title = video_data['videoName']
info.artist = video_data['artistNames']
for s in video_data['videoUrlModels']:
stream_id = self.types_2_id[s['qualityLevel']]
stream_profile = self.types_2_profile[s['qualityLevel']]
info.stream_types.append(stream_id)
info.streams[stream_id] = {'container': 'flv', 'video_profile': stream_profile, 'src' : [s['videoUrl']], 'size': s['fileSize']}
info.stream_types = sorted(info.stream_types, key = self.ids.index)
return info
示例10: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
def prepare(self):
info = VideoInfo(self.name)
self.setup(info)
self.streams_parameter = {}
for stream in self.stream_data:
stream_id = stream_code_to_id[stream['stream_type']]
if not stream_id in info.stream_types:
self.streams_parameter[stream_id] = {
'fileid': stream['stream_fileid'],
'segs': stream['segs']
}
info.streams[stream_id] = {
'container': id_to_container[stream_id],
'video_profile': stream_code_to_profiles[stream_id],
'size': stream['size']
}
info.stream_types.append(stream_id)
self.extract_single(info, stream_id)
info.stream_types = sorted(info.stream_types, key = ids.index)
return info
示例11: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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://player.pc.le.com/player/startup_by_channel_id/1001/{}?host=live.le.com'.format(self.vid)))
info.title = 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)
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
示例12: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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®ion=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
示例13: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
def prepare(self):
info = VideoInfo(self.name, True)
if not self.vid:
html = get_content(self.url)
self.vid = match1(html, 'roomid: (\d+)', '__ROOMID = \'(\d+)\';', '"RoomId":(\d+)')
info.title = match1(html, '"title":"([^"]+)', '<title>([^>]+)<')
info.artist = match1(html, '"Name":"([^"]+)')
api_url = 'http://livestream.plu.cn/live/getlivePlayurl?roomId={}&{}'.format(self.vid, int(time.time()))
data = json.loads(get_content(api_url))['playLines'][0]['urls'] #don't know index 1
for i in data:
if i['ext'] == 'flv':
stream_id = self.supported_stream_types[i['rateLevel'] -1]
info.stream_types.append(stream_id)
info.streams[stream_id] = {'container': 'flv', 'video_profile': self.types_2_profile[stream_id], 'src' : [i['securityUrl']], 'size': 0}
#sort stream_types
types = self.supported_stream_types
types.reverse()
info.stream_types = sorted(info.stream_types, key=types.index)
return info
示例14: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream_id] [as 别名]
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]
if self.url and not self.vid:
html = get_content(self.url)
tvid = match1(html, 'data-player-tvid="([^"]+)"', 'tvid=([^&]+)' , 'tvId:([^,]+)')
videoid = match1(html, 'data-player-videoid="([^"]+)"', 'vid=([^&]+)', 'vid:"([^"]+)')
self.vid = (tvid, videoid)
info.title = match1(html, '<title>([^<]+)').split('-')[0]
tvid, vid = self.vid
data = getVMS(tvid, vid)
if not data['code'] == 'A00000':
for bid in self.id_h5:
h5_data = geth5VMS(tvid, vid, bid)
if h5_data["code"] == "A00000":
stream = self.vd_2_id[bid]
profile = self.id_2_profile[stream]
info.title = h5_data['data']['playInfo']['vn']
info.stream_types.append(stream)
info.streams[stream] = {'container': 'mp4', 'video_profile': profile, 'src' : [h5_data['data']['m3u']], 'size' : 0}
return info
for stream in data['data']['vidl']:
try:
stream_id = self.vd_2_id[stream['vd']]
if stream_id in info.stream_types or stream_id in self.id_ignore:
continue
stream_profile = self.id_2_profile[stream_id]
info.stream_types.append(stream_id)
info.streams[stream_id] = {'video_profile': stream_profile, 'container': 'm3u8', 'src': [stream['m3u']], 'size' : 0}
except:
log.i("vd: {} is not handled".format(stream['vd']))
log.i("info is {}".format(stream))
# why I need do below???
try:
vip_vds = data['data']['ctl']['vip']['bids']
vip_conf = data['data']['ctl']['configs']
except:
info.stream_types = sorted(info.stream_types, key = self.ids.index)
return info
if not 'BD' in info.stream_types:
p1080_vids = []
if 5 in vip_vds:
p1080_vids.append(vip_conf['5']['vid'])
for v in p1080_vids:
p1080_info = getVMS(tvid, v)
if p1080_info['code'] == 'A00000':
p1080_url = p1080_info['data']['m3u']
info.stream_types.append('BD')
info.streams['BD'] = {'video_profile': '1080p', 'container': 'm3u8', 'src': [p1080_url], 'size' : 0}
break
if not '4k' in info.stream_types:
k4_vids = []
if 10 in vip_vds:
k4_vids.append(vip_conf['10']['vid'])
for v in k4_vids:
k4_info = getVMS(tvid, v)
if k4_info['code'] == 'A00000':
k4_url = k4_info['data']['m3u']
info.stream_types.append('4k')
info.streams['4k'] = {'video_profile': '4k', 'container': 'm3u8', 'src': [k4_url], 'size' : 0}
break
info.stream_types = sorted(info.stream_types, key = self.ids.index)
return info