当前位置: 首页>>代码示例>>Python>>正文


Python VideoInfo.streams[profile]方法代码示例

本文整理汇总了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
开发者ID:PureTV,项目名称:ykdl,代码行数:27,代码来源:video.py

示例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
开发者ID:PureTV,项目名称:ykdl,代码行数:24,代码来源:taobao.py


注:本文中的ykdl.videoinfo.VideoInfo.streams[profile]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。