本文整理汇总了Python中ykdl.videoinfo.VideoInfo.extra['ua']方法的典型用法代码示例。如果您正苦于以下问题:Python VideoInfo.extra['ua']方法的具体用法?Python VideoInfo.extra['ua']怎么用?Python VideoInfo.extra['ua']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ykdl.videoinfo.VideoInfo
的用法示例。
在下文中一共展示了VideoInfo.extra['ua']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import extra['ua'] [as 别名]
def prepare(self):
info = VideoInfo(self.name)
add_header('User-Agent', "abcd")
add_header('Referer', "http://acfun.cn/")
self.vid, self.embsig = self.vid
api = "http://player.acfun.cn/flash_data?vid={}&ct={}&ev=3&sign={}&time={}".format(self.vid, self.ct, self.embsig, int(time.time()*1000))
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 'm3u8' in s['stream_type']:
continue
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)
info.extra['ua'] = 'abcd'
return info