本文整理汇总了Python中ykdl.videoinfo.VideoInfo.streams[stream]方法的典型用法代码示例。如果您正苦于以下问题:Python VideoInfo.streams[stream]方法的具体用法?Python VideoInfo.streams[stream]怎么用?Python VideoInfo.streams[stream]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ykdl.videoinfo.VideoInfo
的用法示例。
在下文中一共展示了VideoInfo.streams[stream]方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: letvcloud_download_by_vu
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream] [as 别名]
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
示例2: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream] [as 别名]
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
示例3: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream] [as 别名]
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
示例4: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream] [as 别名]
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
示例5: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream] [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]
info.title = self.name + '_' + str(self.vid)
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
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
示例6: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[stream] [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