• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python http.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _get_streams

    def _get_streams(self):
        res = http.get(self.url)
        match = _embed_re.search(res.text)
        if match:
            res = http.get(match.group(1))

        match = _aptoma_id_re.search(res.text)
        if not match:
            return

        aptoma_id = match.group(1)
        if not _live_re.search(res.text):
            res = http.get(METADATA_URL.format(aptoma_id))
            metadata = http.json(res)
            video_id = metadata["videoId"]
        else:
            video_id = aptoma_id

        res = http.get(VIDEO_INFO_URL, params=dict(id=video_id))
        video = http.json(res, schema=_video_schema)
        streams = {}
        for fmt, providers in video["formats"].items():
            for name, provider in providers.items():
                for ext, playlists in provider.items():
                    for playlist in playlists:
                        url = PLAYLIST_URL_FORMAT.format(**playlist)
                        parser = STREAM_TYPES[fmt]

                        try:
                            streams.update(parser(self.session, url))
                        except IOError as err:
                            self.logger.error("Failed to extract {0} streams: {1}",
                                              fmt.upper(), err)

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


示例2: _get_streams

    def _get_streams(self):
        headers = {
            "Referer": self.url
        }
        res = http.get(self.url, headers=headers)

        match = _ddos_re.search(res.text)
        if (match):
            headers["Cookie"] = match.group(1)
            res = http.get(self.url, headers=headers)

        match = _stream_re.search(res.text)
        if not match:
            return

        stream_id = match.group(1)
        streams = {}
        for name, url_suffix in QUALITIES.items():
            url = HLS_URL_FORMAT.format(stream_id, url_suffix)
            if not self._check_stream(url):
                continue

            streams[name] = HLSStream(self.session, url)

        return streams
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:25,代码来源:goodgame.py


示例3: _get_streams

    def _get_streams(self):
        user = self.login(self.options.get("email"), self.options.get("password"))
        if user:
            self.logger.debug("Logged in to Schoolism as {0}", user)
            res = http.get(self.url, headers={"User-Agent": useragents.SAFARI_8})
            lesson_playlist = self.playlist_schema.validate(res.text)

            part = self.options.get("part")

            self.logger.info("Attempting to play lesson Part {0}", part)
            found = False

            # make request to key-time api, to get key specific headers
            res = http.get(self.key_time_url, headers={"User-Agent": useragents.SAFARI_8})

            for i, video in enumerate(lesson_playlist, 1):
                if video["sources"] and i == part:
                    found = True
                    for source in video["sources"]:
                        for s in HLSStream.parse_variant_playlist(self.session,
                                                                  source["src"],
                                                                  headers={"User-Agent": useragents.SAFARI_8,
                                                                           "Referer": self.url}).items():
                            yield s

            if not found:
                self.logger.error("Could not find lesson Part {0}", part)
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:27,代码来源:schoolism.py


示例4: _get_streams

 def _get_streams(self):
     if "eltrecetv.com.ar/vivo" in self.url.lower():
         try:
             http.headers = {'Referer': self.url,
                             'User-Agent': useragents.ANDROID}
             res = http.get('https://api.iamat.com/metadata/atcodes/eltrece')
             yt_id = parse_json(res.text)["atcodes"][0]["context"]["ahora"]["vivo"]["youtubeVideo"]
             yt_url = "https://www.youtube.com/watch?v={0}".format(yt_id)
             return self.session.streams(yt_url)
         except BaseException:
             self.logger.info("Live content is temporarily unavailable. Please try again later.")
     else:
         try:
             http.headers = {'Referer': self.url,
                             'User-Agent': useragents.CHROME}
             res = http.get(self.url)
             _player_re = re.compile(r'''data-kaltura="([^"]+)"''')
             match = _player_re.search(res.text)
             if not match:
                 return
             entry_id = parse_json(match.group(1).replace(""", '"'))["entryId"]
             hls_url = "https://vodgc.com/p/111/sp/11100/playManifest/entryId/{0}/format/applehttp/protocol/https/a.m3u8".format(entry_id)
             return HLSStream.parse_variant_playlist(self.session, hls_url)
         except BaseException:
             self.logger.error("The requested VOD content is unavailable.")
开发者ID:justastranger,项目名称:Twitchy,代码行数:25,代码来源:eltrecetv.py


示例5: _get_streams

    def _get_streams(self):
        flashvars = http.get(self.url, schema=_flashvars_schema)
        if not flashvars:
            return

        params = {
            "rt": "json",
            "lc": "en_US",
            "pt": "view",
            "bpw": "",
            "bid": flashvars["id"],
            "adok": "",
            "bno": ""
        }
        
        if re.search(_url_re_tw, self.url):
            res = http.get(VIEW_LIVE_API_URL_TW, params=params)
        elif re.search(_url_re_jp, self.url):
            res = http.get(VIEW_LIVE_API_URL_JP, params=params)
        else:
            res = http.get(VIEW_LIVE_API_URL, params=params)
            
        streams = http.json(res, schema=_view_live_schema)

        for stream in streams:
            stream_name = "{0}p".format(stream["bps"])
            stream_params = {
                "rtmp": stream["purl"],
                "live": True
            }
            yield stream_name, RTMPStream(self.session, stream_params)
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:31,代码来源:afreecatv.py


示例6: _get_streams

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

        headers = {
            "Referer": self.url,
            "User-Agent": useragents.FIREFOX
        }

        if domain == "canlitv.plus":
            res = http.get(EMBED_URL_1.format(channel), headers=headers)
        elif domain == "ecanlitvizle.net":
            res = http.get(EMBED_URL_2.format(channel), headers=headers)
        else:
            res = http.get(self.url, headers=headers)

        url_match = _m3u8_re.search(res.text)

        if url_match:
            hls_url = url_match.group("url")

            if domain in ("canlitvlive.live", "canlitvlive.site"):
                hls_url = "http:" + hls_url

            self.logger.debug("Found URL: {0}".format(hls_url))

            try:
                s = []
                for s in HLSStream.parse_variant_playlist(self.session, hls_url).items():
                    yield s
                if not s:
                    yield "live", HLSStream(self.session, hls_url)
            except IOError as err:
                self.logger.error("Failed to extract streams: {0}", err)
开发者ID:justastranger,项目名称:Twitchy,代码行数:35,代码来源:canlitv.py


示例7: _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


示例8: _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


示例9: _get_streams

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

        res = http.get(self.FORMATS_URL.format(channel))
        streams = 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 = http.get(api_url)
                    video_url = 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:amadu80,项目名称:repository.xvbmc,代码行数:31,代码来源:playtv.py


示例10: _get_streams

    def _get_streams(self):
        match = _url_re.match(self.url)
        if not match:
            return

        channel, media_id = match.group("channel", "media_id")
        self.logger.debug("Matched URL: channel={0}, media_id={1}".format(channel, media_id))
        if not media_id:
            res = http.get(LIVE_API.format(channel))
            livestream = http.json(res, schema=_live_schema)
            if livestream.get("media_hosted_media"):
                hosted = _live_schema.validate(livestream["media_hosted_media"])
                self.logger.info("{0} is hosting {1}", livestream["media_user_name"], hosted["media_user_name"])
                livestream = hosted

            if not livestream["media_is_live"]:
                return

            media_id = livestream["media_id"]
            media_type = "live"
        else:
            media_type = "video"

        res = http.get(PLAYER_API.format(media_type, media_id))
        player = http.json(res, schema=_player_schema)

        if media_type == "live":
            return self._get_live_streams(player)
        else:
            return self._get_video_streams(player)
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:30,代码来源:hitbox.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_qq_streams

    def _get_qq_streams(self, vid):
        res = http.get(QQ_STREAM_INFO_URL % (vid, 1))
        info = http.json(res, schema=_qq_schema)
        yield "live", HTTPStream(self.session, info)

        res = http.get(QQ_STREAM_INFO_URL % (vid, 2))
        info = http.json(res, schema=_qq_schema)
        yield "live_http", HLSStream(self.session, info)
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:8,代码来源:tga.py


示例13: _get_stream_info

    def _get_stream_info(self, url):
        res = http.get(url, headers=HEADERS)
        match = re.search(r"embed.swf\?p=(\d+)", res.text)
        if not match:
            return
        program = match.group(1)
        res = http.get(BEAT_PROGRAM.format(program), headers=HEADERS)

        return http.json(res, schema=_schema)
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:9,代码来源:beattv.py


示例14: _get_live_streams

    def _get_live_streams(self):
        meta = self._get_meta()
        stream = [x for x in meta['streams'] if x['type'] == 'hls'][0]['url']

        url = 'http://ida.omroep.nl/aapi/?type=jsonp&stream={}&token={}'.format(stream, self.get_token())
        streamdata = http.get(url, headers=HTTP_HEADERS).json()
        deeplink = http.get(streamdata['stream'], headers=HTTP_HEADERS).text
        deeplink = re.compile('"(.*?)"', re.DOTALL + re.IGNORECASE).search(deeplink).group(1)
        playlist_url = deeplink.replace("\\/", "/")
        return HLSStream.parse_variant_playlist(self.session, playlist_url)
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:10,代码来源:npo.py


示例15: _get_live_streams

 def _get_live_streams(self, subdomain):
     """
     Get the live stream in a particular language
     :param subdomain:
     :return:
     """
     res = http.get(self._live_api_url.format(subdomain))
     live_res = http.json(res, schema=self._live_schema)
     api_res = http.get(live_res[u"url"])
     stream_data = http.json(api_res, schema=self._stream_api_schema)
     return HLSStream.parse_variant_playlist(self.session, stream_data[u'primary'])
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:11,代码来源:euronews.py


示例16: _get_vod_streams

    def _get_vod_streams(self):
        # 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.VOD_API_URL.format(video_id))
        streams = http.json(res, schema=self._vod_api_schema)
        return streams
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:11,代码来源:bloomberg.py


示例17: _get_streams

    def _get_streams(self):
        res = http.get(self.url, headers={"User-Agent": useragents.CHROME})
        m = self.js_re.search(res.text)
        if m:
            self.logger.debug("Found js key: {0}", m.group(1))
            js_url = m.group(0)
            res = http.get(urljoin(self.url, js_url))

            for url in self.player_re.findall(res.text):
                if "adblock" not in url:
                    yield "live", HLSStream(self.session, url)
开发者ID:justastranger,项目名称:Twitchy,代码行数:11,代码来源:brittv.py


示例18: _get_vod_streams

    def _get_vod_streams(self):
        url = 'http://ida.omroep.nl/odi/?prid={}&puboptions=adaptive,h264_bb,h264_sb,h264_std&adaptive=no&part=1&token={}'\
            .format(quote(self.npo_id), quote(self.get_token()))
        res = http.get(url, headers=HTTP_HEADERS);

        data = res.json()

        streams = {}
        stream = http.get(data['streams'][0].replace('jsonp', 'json'), headers=HTTP_HEADERS).json()
        streams['best'] = streams['high'] = HTTPStream(self.session, stream['url'])
        return streams
开发者ID:coder-alpha,项目名称:CcloudTv.bundle,代码行数:11,代码来源:npo.py


示例19: _get_streams

    def _get_streams(self):
        http.headers = {"User-Agent": useragents.CHROME}
        res = http.get(self.url)
        iframe_url = self.find_iframe(res)

        if iframe_url:
            self.logger.debug("Found iframe: {0}", iframe_url)
            res = http.get(iframe_url, headers={"Referer": self.url})
            stream_url = update_scheme(self.url, self.stream_schema.validate(res.text))
            return HLSStream.parse_variant_playlist(self.session,
                                                    stream_url,
                                                    headers={"User-Agent": useragents.CHROME})
开发者ID:justastranger,项目名称:Twitchy,代码行数:12,代码来源:cdnbg.py


示例20: _get_streams

    def _get_streams(self):
        """
        Get the config object from the page source and call the
        API to get the list of streams
        :return:
        """
        # attempt a login
        self.login()

        res = http.get(self.url)
        # decode the config for the page
        matches = self.config_re.finditer(res.text)
        try:
            config = self.config_schema.validate(dict(
                [m.group("key", "value") for m in matches]
            ))
        except PluginError:
            return

        if config["selectedVideoHID"]:
            self.logger.debug("Found video hash ID: {0}", config["selectedVideoHID"])
            api_url = urljoin(self.url, urljoin(config["videosURL"], config["selectedVideoHID"]))
        elif config["livestreamURL"]:
            self.logger.debug("Found live stream URL: {0}", config["livestreamURL"])
            api_url = urljoin(self.url, config["livestreamURL"])
        else:
            return

        ares = http.get(api_url)
        data = http.json(ares, schema=self.api_schema)
        viewing_urls = data["viewing_urls"]

        if "error" in viewing_urls:
            self.logger.error("Failed to load streams: {0}", viewing_urls["error"])
        else:
            for url in viewing_urls["urls"]:
                try:
                    label = "{0}p".format(url.get("res", url["label"]))
                except KeyError:
                    label = "live"

                if url["type"] == "rtmp/mp4" and RTMPStream.is_usable(self.session):
                    params = {
                        "rtmp": url["src"],
                        "pageUrl": self.url,
                        "live": True,
                    }
                    yield label, RTMPStream(self.session, params)

                elif url["type"] == "application/x-mpegURL":
                    for s in HLSStream.parse_variant_playlist(self.session, url["src"]).items():
                        yield s
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:52,代码来源:liveedu.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python http.json函数代码示例发布时间:2022-05-27
下一篇:
Python plugin.Plugin类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap