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


Python stream.HDSStream类代码示例

本文整理汇总了Python中streamlink.stream.HDSStream的典型用法代码示例。如果您正苦于以下问题:Python HDSStream类的具体用法?Python HDSStream怎么用?Python HDSStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_hds_stream

 def test_hds_stream(self):
     stream = HDSStream(self.session, "http://test.se/", "http://test.se/stream.f4m",
                        "http://test.se/stream/1.bootstrap", headers={"User-Agent": "Test"})
     self.assertEqual(
         {"type": "hds",
          "baseurl": "http://test.se/",
          "bootstrap": "http://test.se/stream/1.bootstrap",
          "url": "http://test.se/stream.f4m",
          "metadata": None,
          "headers": {"User-Agent": "Test"},
          "params": {}},
         stream.__json__()
     )
开发者ID:sheldon0531,项目名称:streamlink,代码行数:13,代码来源:test_stream_json.py

示例2: _get_streams

    def _get_streams(self):
        res = self.session.http.get(self.url)
        match = _player_js.search(res.text)
        if match:
            player_js = match.group(0)
            self.logger.info("Found player js {0}", player_js)
        else:
            self.logger.info("Didn't find player js. Probably this page doesn't contain a video")
            return

        res = self.session.http.get(player_js)

        jsonp_start = res.text.find('(') + 1
        jsonp_end = res.text.rfind(')')

        if jsonp_start <= 0 or jsonp_end <= 0:
            self.logger.info("Couldn't extract json metadata from player.js: {0}", player_js)
            return

        json_s = res.text[jsonp_start:jsonp_end]

        stream_metadata = json.loads(json_s)

        hds_url = stream_metadata['mediaResource']['dflt']['videoURL']
        hds_url = update_scheme(self.url, hds_url)

        return HDSStream.parse_manifest(self.session, hds_url).items()
开发者ID:sheldon0531,项目名称:streamlink,代码行数:27,代码来源:sportschau.py

示例3: _get_streams

    def _get_streams(self):
        match = _url_re.match(self.url)
        video_id = match.group("video_id")
        res = http.get(ASSET_URL.format(video_id))
        assets = http.xml(res, schema=_asset_schema)

        streams = {}
        for asset in assets:
            base = asset["base"]
            url = asset["url"]

            if urlparse(url).path.endswith(".f4m"):
                streams.update(
                    HDSStream.parse_manifest(self.session, url, pvswf=SWF_URL)
                )
            elif base.startswith("rtmp"):
                name = "{0}k".format(asset["bitrate"])
                params = {
                    "rtmp": asset["base"],
                    "playpath": url,
                    "live": True
                }
                streams[name] = RTMPStream(self.session, params)

        return streams
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:25,代码来源:tv4play.py

示例4: _get_streams

    def _get_streams(self):

        # Discover root
        match = _url_re.search(self.url)
        root = match.group(1)

        # Download main URL
        res = http.get(self.url)

        # Find playlist
        match = _playlist_re.search(res.text)
        playlist_url = root + match.group(1) + "d"

        # Download playlist
        res = http.get(playlist_url)

        # Find manifest
        match = _manifest_re.search(res.text)
        manifest_url = match.group(1)

        # Find SWF
        match = _swf_re.search(res.text)
        swf_url = match.group(1)

        streams = {}
        streams.update(
            HDSStream.parse_manifest(self.session, manifest_url, pvswf=swf_url)
        )

        return streams
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:30,代码来源:antenna.py

示例5: _get_streams

    def _get_streams(self):
        url, params = parse_url_params(self.url)

        urlnoproto = self._url_re.match(url).group(2)
        urlnoproto = update_scheme("http://", urlnoproto)

        return HDSStream.parse_manifest(self.session, urlnoproto, **params)
开发者ID:justastranger,项目名称:Twitchy,代码行数:7,代码来源:hds.py

示例6: _get_vod_streams

    def _get_vod_streams(self, params):
        manifest_url = params.get("autoURL")
        if not manifest_url:
            return

        res = http.get(manifest_url)
        if res.headers.get("Content-Type") == "application/f4m+xml":
            streams = HDSStream.parse_manifest(self.session, res.url)

            # TODO: Replace with "yield from" when dropping Python 2.
            for __ in streams.items():
                yield __
        elif res.headers.get("Content-Type") == "application/vnd.apple.mpegurl":
            streams = HLSStream.parse_variant_playlist(self.session, res.url)

            # TODO: Replace with "yield from" when dropping Python 2.
            for __ in streams.items():
                yield __
        else:
            manifest = http.json(res, schema=_vod_manifest_schema)
            for params in manifest["alternates"]:
                name = "{0}p".format(params["height"])
                stream = self._create_flv_playlist(params["template"])
                yield name, stream

                failovers = params.get("failover", [])
                for failover in failovers:
                    stream = self._create_flv_playlist(failover)
                    yield name, stream
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:29,代码来源:dailymotion.py

示例7: _get_live_streams

    def _get_live_streams(self, params, swf_url):
        for key, quality in QUALITY_MAP.items():
            key_url = "{0}URL".format(key)
            url = params.get(key_url)

            if not url:
                continue

            try:
                res = http.get(url, exception=IOError)
            except IOError:
                continue

            if quality == "hds":
                streams = HDSStream.parse_manifest(self.session, res.url)
                for name, stream in streams.items():
                    if key == "source":
                        name += "+"

                    yield name, stream
            elif res.text.startswith("rtmp"):
                match = _rtmp_re.match(res.text)
                if not match:
                    continue

                stream = RTMPStream(self.session, {
                    "rtmp": match.group("host"),
                    "app": match.group("app"),
                    "playpath": match.group("playpath"),
                    "swfVfy": swf_url,
                    "live": True
                })

                yield quality, stream
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:34,代码来源:dailymotion.py

示例8: mediaselector

    def mediaselector(self, vpid):
        urls = defaultdict(set)
        for platform in self.platforms:
            url = self.api_url.format(vpid=vpid, vpid_hash=self._hash_vpid(vpid),
                                      platform=platform)
            log.debug("Info API request: {0}", url)
            medias = self.session.http.get(url, schema=self.mediaselector_schema)
            for media in medias:
                for connection in media["connection"]:
                    urls[connection.get("transferFormat")].add(connection["href"])

        for stream_type, urls in urls.items():
            log.debug("{0} {1} streams", len(urls), stream_type)
            for url in list(urls):
                try:
                    if stream_type == "hds":
                        for s in HDSStream.parse_manifest(self.session,
                                                          url).items():
                            yield s
                    if stream_type == "hls":
                        for s in HLSStream.parse_variant_playlist(self.session,
                                                                  url).items():
                            yield s
                    if stream_type == "dash":
                        for s in DASHStream.parse_manifest(self.session,
                                                           url).items():
                            yield s
                    log.debug("  OK:   {0}", url)
                except:
                    log.debug("  FAIL: {0}", url)
开发者ID:sheldon0531,项目名称:streamlink,代码行数:30,代码来源:bbciplayer.py

示例9: _get_streams

    def _get_streams(self):
        match = self._url_re.match(self.url)
        channel = match.group('channel')

        res = self.session.http.get(self.FORMATS_URL.format(channel))
        streams = self.session.http.json(res, schema=self._formats_schema)['streams']
        if streams == []:
            self.logger.error('Channel may be geo-restricted, not directly provided by PlayTV or not freely available')
            return

        for language in streams:
            for protocol, bitrates in list(streams[language].items()):
                # - Ignore non-supported protocols (RTSP, DASH)
                # - Ignore deprecated Flash (RTMPE/HDS) streams (PlayTV doesn't provide anymore a Flash player)
                if protocol in ['rtsp', 'flash', 'dash', 'hds']:
                    continue

                for bitrate in bitrates['bitrates']:
                    if bitrate['value'] == 0:
                        continue
                    api_url = self.API_URL.format(channel, protocol, language, bitrate['value'])
                    res = self.session.http.get(api_url)
                    video_url = self.session.http.json(res, schema=self._api_schema)['url']
                    bs = '{0}k'.format(bitrate['value'])

                    if protocol == 'hls':
                        for _, stream in HLSStream.parse_variant_playlist(self.session, video_url).items():
                            yield bs, stream
                    elif protocol == 'hds':
                        for _, stream in HDSStream.parse_manifest(self.session, video_url).items():
                            yield bs, stream
开发者ID:sheldon0531,项目名称:streamlink,代码行数:31,代码来源:playtv.py

示例10: _get_vod_stream

    def _get_vod_stream(self):
        vod_url = self.url
        if vod_url.endswith('/'):
            vod_url = vod_url[:-1]

        json_url = '{0}.securevideo.json'.format(vod_url)

        res = http.get(json_url)
        match = _json_re.search(res.text)
        if not match:
            return
        data = parse_json(match.group(1))

        res = http.get(API_VOD.format(data['clientid'], data['mzid']))
        data = http.json(res, schema=_stream_schema)

        for d in data['targetUrls']:
            if d['type'] == 'HDS':
                hds_url = d['url']
                for s in HDSStream.parse_manifest(self.session, hds_url).items():
                    yield s

            if d['type'] == 'HLS':
                hls_url = d['url']
                for s in HLSStream.parse_variant_playlist(self.session, hls_url).items():
                    yield s
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:26,代码来源:vrtbe.py

示例11: _get_streams

    def _get_streams(self):
        # Get video ID and channel from URL
        match = self._url_re.match(self.url)
        video_id = match.group('video_id')
        if video_id is None:
            # Retrieve URL page and search for video ID
            res = http.get(self.url)
            match = self._video_id_re.search(res.text)
            if match is None:
                return
            video_id = match.group('video_id')

        res = http.get(self.API_URL.format(video_id))
        videos = http.json(res, schema=self._api_schema)
        parsed = []
        headers = {'User-Agent': self._user_agent}

        # Some videos may be also available on Dailymotion (especially on CNews)
        if videos['ID_DM'] != '':
            for stream in self.session.streams('https://www.dailymotion.com/video/' + videos['ID_DM']).items():
                yield stream

        for quality, video_url in list(videos['MEDIA']['VIDEOS'].items()):
            # Ignore empty URLs
            if video_url == '':
                continue

            # Ignore duplicate video URLs
            if video_url in parsed:
                continue
            parsed.append(video_url)

            try:
                # HDS streams don't seem to work for live videos
                if '.f4m' in video_url and 'LIVE' not in videos['TYPE']:
                    for stream in HDSStream.parse_manifest(self.session,
                                                           video_url,
                                                           params={'hdcore': self.HDCORE_VERSION},
                                                           headers=headers).items():
                        yield stream
                elif '.m3u8' in video_url:
                    for stream in HLSStream.parse_variant_playlist(self.session,
                                                                   video_url,
                                                                   headers=headers).items():
                        yield stream
                elif '.mp4' in video_url:
                    # Get bitrate from video filename
                    match = self._mp4_bitrate_re.match(video_url)
                    if match is not None:
                        bitrate = match.group('bitrate')
                    else:
                        bitrate = quality
                    yield bitrate, HTTPStream(self.session,
                                              video_url,
                                              params={'secret': self.SECRET},
                                              headers=headers)
            except IOError as err:
                if '403 Client Error' in str(err):
                    self.logger.error('Failed to access stream, may be due to geo-restriction')
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:59,代码来源:canalplus.py

示例12: _get_smil_streams

    def _get_smil_streams(self, info):
        res = http.get(info["_stream"])
        smil = http.xml(res, "SMIL config", schema=_smil_schema)

        for video in smil["videos"]:
            url = "{0}/{1}{2}".format(smil["base"], video, HDCORE_PARAMETER)
            streams = HDSStream.parse_manifest(self.session, url, pvswf=SWF_URL, is_akamai=smil["cdn"] == "akamai")

            for stream in streams.items():
                yield stream
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:10,代码来源:ard_mediathek.py

示例13: _get_smil_streams

    def _get_smil_streams(self, info):
        res = http.get(info["_stream"])
        smil = http.xml(res, "SMIL config", schema=_smil_schema)

        for video in smil["videos"]:
            url = "{0}/{1}{2}".format(smil["base"], video, HDCORE_PARAMETER)
            streams = HDSStream.parse_manifest(self.session, url, pvswf=SWF_URL)

            # TODO: Replace with "yield from" when dropping Python 2.
            for stream in streams.items():
                yield stream
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:11,代码来源:ard_mediathek.py

示例14: _get_hds_streams

    def _get_hds_streams(self, channel):
        channel = self.hds_channel_remap.get(channel, "{0}live".format(channel))
        manifest_url = http.get(self.api_url.format(channel),
                                params={"getURL": 1},
                                headers={"User-Agent": useragents.FIREFOX}).text

        for s in HDSStream.parse_manifest(self.session,
                                          manifest_url,
                                          pvswf=self.swf_url,
                                          headers={"User-Agent": useragents.FIREFOX}).items():
            yield s
开发者ID:justastranger,项目名称:Twitchy,代码行数:11,代码来源:tf1.py

示例15: mediaselector

 def mediaselector(self, vpid):
     for platform in self.platforms:
         url = self.api_url.format(vpid=vpid, vpid_hash=self._hash_vpid(vpid), platform=platform)
         self.logger.debug("Info API request: {0}", url)
         stream_urls = http.get(url, schema=self.mediaselector_schema)
         for media in stream_urls:
             for connection in media["connection"]:
                 if connection.get("transferFormat") == "hds":
                     for s in HDSStream.parse_manifest(self.session, connection["href"]).items():
                         yield s
                 if connection.get("transferFormat") == "hls":
                     for s in HLSStream.parse_variant_playlist(self.session, connection["href"]).items():
                         yield s
开发者ID:justastranger,项目名称:Twitchy,代码行数:13,代码来源:bbciplayer.py


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