本文整理汇总了Python中ykdl.videoinfo.VideoInfo.streams[profile]方法的典型用法代码示例。如果您正苦于以下问题:Python VideoInfo.streams[profile]方法的具体用法?Python VideoInfo.streams[profile]怎么用?Python VideoInfo.streams[profile]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ykdl.videoinfo.VideoInfo
的用法示例。
在下文中一共展示了VideoInfo.streams[profile]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[profile] [as 别名]
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
示例2: prepare
# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import streams[profile] [as 别名]
def prepare(self):
info = VideoInfo(self.name)
html = get_content(self.url)
self.vid = match1(html, "(\d+)\.swf")
xml = get_content("http://cloud.video.taobao.com/videoapi/info.php?vid={}".format(self.vid))
doc = parseString(xml)
videos = doc.getElementsByTagName("videos")[0]
n = 0
for video in videos.getElementsByTagName('video'):
if not n % 2:
lenth = video.getElementsByTagName('length')[0].firstChild.nodeValue
url = video.getElementsByTagName('video_url')[0].firstChild.nodeValue
profile = self.stream_2_id[video.getElementsByTagName('type')[0].firstChild.nodeValue]
info.stream_types.append(profile)
info.streams[profile] = {'container': 'flv', 'video_profile': profile, 'src' : [url+'/start_0/end_{}/1.flv'.format(lenth)], 'size': int(lenth)}
info.stream_types = sorted(info.stream_types, key = self.stream_ids.index)
return info