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


Python VideoInfo.stream_types[0]方法代码示例

本文整理汇总了Python中ykdl.videoinfo.VideoInfo.stream_types[0]方法的典型用法代码示例。如果您正苦于以下问题:Python VideoInfo.stream_types[0]方法的具体用法?Python VideoInfo.stream_types[0]怎么用?Python VideoInfo.stream_types[0]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ykdl.videoinfo.VideoInfo的用法示例。


在下文中一共展示了VideoInfo.stream_types[0]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prepare

# 需要导入模块: from ykdl.videoinfo import VideoInfo [as 别名]
# 或者: from ykdl.videoinfo.VideoInfo import stream_types[0] [as 别名]
    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        self.vid = match1(html, '"qipuId":(\d+),')
        title = match1(html, '"roomTitle":"([^"]+)",')
        artist = match1(html, '"anchorNickname":"([^"]+)",')
        info.title = u'{} - {}'.format(title, artist)
        info.artist = artist

        data = getlive(self.vid)
        self.logger.debug('data:\n' + str(data))
        assert data['code'] == 'A00000', data.get('msg', 'can\'t play this live video!!')
        data = data['data']

        for stream in data['streams']:
            # TODO: parse more format types.
            # Streams which use formatType 'TS' are slow,
            # and rolling playback use formatType 'HLFLV' with scheme 'hcdnlive://'.
            # Its host and path encoded as like:
            #   'AMAAAAD3PV2R2QI7MXRQ4L2BD5Y...'
            # the real url is:
            #   'https://hlslive.video.iqiyi.com/live/{hl_slid}.flv?{params}'
            # Request it, the response is a json data which contains CDN informations.
            if stream['formatType'] == 'TS':
                m3u8 = stream['url']
                # miswrote 'streamType' to 'steamType'
                stream_type = stream['steamType']
                stream_profile = stream['screenSize']
                stream_id = self.type_2_id[stream_type]
                info.stream_types.append(stream_id)
                info.streams[stream_id] = {
                    'video_profile': stream_profile,
                    'container': 'm3u8',
                    'src' : [m3u8],
                    'size': float('inf')
                }

        assert info.stream_types, 'can\'t play this live video!!'
        if len(info.stream_types) == 1:
            info.streams['current'] = info.streams.pop(info.stream_types[0])
            info.stream_types[0] = 'current'
        else:
            info.stream_types = sorted(info.stream_types, key=self.ids.index)

        return info
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:47,代码来源:live.py


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