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


Python RTMPStream.is_usable方法代码示例

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


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

示例1: _get_live_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_live_streams(self, *args, **kwargs):
        streams = defaultdict(list)

        if RTMPStream.is_usable(self.session):
            try:
                for name, stream in self._get_desktop_streams(*args, **kwargs).items():
                    streams[name].append(stream)

            except PluginError as err:
                self.logger.error("Error when fetching desktop streams: {0}",
                                  err)
            except NoStreamsError:
                pass
        else:
            self.logger.warning("rtmpdump is required to access the desktop "
                                "streams, but it could not be found")

        try:
            for name, stream in self._get_mobile_streams(*args, **kwargs).items():
                # Justin.tv streams have a iphone prefix, so let's
                # strip it to keep it consistent with Twitch.
                name = name.replace("iphone", "")
                streams[name].append(stream)

        except PluginError as err:
            self.logger.error("Error when fetching mobile streams: {0}",
                              err)
        except NoStreamsError:
            pass

        return streams
开发者ID:bashtech,项目名称:livestreamer,代码行数:33,代码来源:justintv_common.py

示例2: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        channelid = urlparse(self.url).path.rstrip("/").rpartition("/")[-1].lower()

        self.logger.debug("Fetching stream info")
        headers = {"Referer": self.url}
        options = dict(id=channelid)
        res = urlget(self.StreamInfoURL, headers=headers, params=options)
        json = res_json(res, "stream info JSON")

        if not isinstance(json, dict):
            raise PluginError("Invalid JSON response")

        if not ("rtmp" in json and "streamname" in json):
            raise NoStreamsError(self.url)

        if not RTMPStream.is_usable(self.session):
            raise PluginError("rtmpdump is not usable and required by Owncast plugin")

        rtmp = json["rtmp"]
        playpath = json["streamname"]

        streams = {}
        streams["live"] = RTMPStream(
            self.session, {"rtmp": rtmp, "pageUrl": self.url, "swfUrl": self.SWFURL, "playpath": playpath, "live": True}
        )

        return streams
开发者ID:reduced111,项目名称:livestreamer,代码行数:29,代码来源:owncast.py

示例3: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        self.channelname = self._get_channel_name(self.url)

        if not self.channelname:
            raise NoStreamsError(self.url)

        streams = {}

        if RTMPStream.is_usable(self.session):
            try:
                rtmpstreams = self._get_rtmp_streams()
                streams.update(rtmpstreams)
            except PluginError as err:
                self.logger.error("Error when fetching RTMP stream info: {0}", str(err))
        else:
            self.logger.warning("rtmpdump is not usable, only HLS streams will be available")

        try:
            hlsstreams = self._get_hls_streams()

            for name, stream in hlsstreams.items():
                if name in streams:
                    streams[name] = [streams[name], stream]
                else:
                    streams[name] = stream

        except PluginError as err:
            self.logger.error("Error when fetching HLS stream info: {0}", str(err))

        return streams
开发者ID:ToadKing,项目名称:livestreamer,代码行数:32,代码来源:justintv.py

示例4: _get_live_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_live_streams(self):
        streams = defaultdict(list)

        if RTMPStream.is_usable(self.session):
            try:
                for name, stream in self._get_desktop_streams().items():
                    streams[name].append(stream)

            except PluginError as err:
                self.logger.error("Error when fetching desktop streams: {0}",
                                  err)
            except NoStreamsError:
                pass
        else:
            self.logger.warning("rtmpdump is not usable, "
                                "only mobile streams may be available")

        try:
            for name, stream in self._get_mobile_streams().items():
                # Justin.tv streams have a iphone prefix, so let's
                # strip it to keep it consistent with Twitch.
                name = name.replace("iphone", "")
                streams[name].append(stream)

        except PluginError as err:
            self.logger.error("Error when fetching mobile streams: {0}",
                              err)
        except NoStreamsError:
            pass

        return streams
开发者ID:karlo2105,项目名称:livestreamer,代码行数:33,代码来源:justintv_common.py

示例5: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self, type):
        self.channelname = self._get_channel_name(self.url)

        if not self.channelname:
            raise NoStreamsError(self.url)

        streams = {}
        
        if type in (None, StreamType.RTMP):
            if RTMPStream.is_usable(self.session):
                try:
                    rtmpstreams = self._get_rtmp_streams()
                    streams.update(rtmpstreams)
                except PluginError as err:
                    self.logger.error("Error when fetching RTMP stream info: {0}", str(err))
            else:
                self.logger.warning("rtmpdump is not usable, only HLS streams will be available")

        if type in (None, StreamType.HLS):
            try:
                hlsstreams = self._get_hls_streams()
                if len(streams) > 0:
                    hlssuffix = "_hls"
                else:
                    hlssuffix = ""

                for name, stream in hlsstreams.items():
                    streams[name + hlssuffix] = stream
            except PluginError as err:
                self.logger.error("Error when fetching HLS stream info: {0}", str(err))

        return streams
开发者ID:derekzhang79,项目名称:livestreamer,代码行数:34,代码来源:justintv.py

示例6: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        if not RTMPStream.is_usable(self.session):
            self.logger.warning("rtmpdump is not usable, only HDS streams will be available")

        self.logger.debug("Fetching stream info")
        match = re.search("/\w*/(live|video)*/(\d+)", self.url)
        if not match:
            return

        stream_id = match.group(2)
        res = http.get(API_URL, params=dict(ak="web", id=stream_id))
        root = parse_xml(res.text.encode("utf8"))

        streams = {}
        for formitaet in root.iter('formitaet'):
            url = formitaet.find('url').text
            quality = formitaet.find('quality').text

            if formitaet.get('basetype') == "h264_aac_f4f_http_f4m_http":
                hds_streams = HDSStream.parse_manifest(self.session, url)
                streams.update(hds_streams)
            elif formitaet.get('basetype') == 'h264_aac_mp4_rtmp_zdfmeta_http':
                streams[quality] = RTMPStream(self.session, {
                    "rtmp": self._get_stream(url),
                    "pageUrl": self.url,
                })

        return streams
开发者ID:JamesHarperl,项目名称:livestreamer,代码行数:30,代码来源:zdf_mediathek.py

示例7: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        if not RTMPStream.is_usable(self.session):
            raise PluginError("rtmpdump is not usable and required by Filmon plugin")

        self.logger.debug("Fetching stream info")
        self.rsession = requests.session()
        res = urlget(self.url, session=self.rsession)

        match = re.search("movie_id=(\d+)", res.text)
        if match:
            return self._get_vod_stream(match.group(1))

        match = re.search("/channels/(\d+)/extra_big_logo.png", res.text)
        if not match:
            return

        channel_id = match.group(1)
        streams = {}
        for quality in ("low", "high"):
            try:
                streams[quality] = self._get_stream(channel_id, quality)
            except NoStreamsError:
                pass

        return streams
开发者ID:Am2k,项目名称:livestreamer,代码行数:27,代码来源:filmon.py

示例8: _get_rtmp_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_rtmp_streams(self, swfurl):
        if not RTMPStream.is_usable(self.session):
            raise NoStreamsError(self.url)

        self.logger.debug("Fetching RTMP stream info")

        res = http.get(swfurl)
        swf = swfdecompress(res.content)
        match = re.search("customURL[^h]+(https://.*?)\\\\", swf)

        if not match:
            raise NoStreamsError(self.url)

        res = http.get(match.group(1))
        rtmp, playpath = rtmpparse(res.text)

        params = {
            "rtmp": rtmp,
            "pageUrl": self.url,
            "playpath": playpath,
            "live": True
        }

        match = re.search("file[^h]+(https?://.*?.swf)", swf)
        if match:
            params["swfUrl"] = match.group(1)

        return RTMPStream(self.session, params)
开发者ID:3cky,项目名称:livestreamer,代码行数:30,代码来源:dmcloud.py

示例9: _get_streams_from_rtmp

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams_from_rtmp(self):
        password = self.options.get("password")
        module_info = self._get_module_info("channel", self.channel_id,
                                            password)
        if not module_info:
            raise NoStreamsError(self.url)

        providers = module_info.get("stream")
        if providers == "offline":
            raise NoStreamsError(self.url)
        elif not isinstance(providers, list):
            raise PluginError("Invalid stream info: {0}".format(providers))

        streams = {}
        for provider in filter(valid_provider, providers):
            provider_url = provider.get("url")
            provider_name = provider.get("name")
            provider_streams = provider.get("streams")

            for stream_index, stream_info in enumerate(provider_streams):
                stream = None
                stream_height = int(stream_info.get("height", 0))
                stream_name = stream_info.get("description")

                if not stream_name:
                    if stream_height:
                        if not stream_info.get("isTranscoded"):
                            stream_name = "{0}p+".format(stream_height)
                        else:
                            stream_name = "{0}p".format(stream_height)
                    else:
                        stream_name = "live"

                if stream_name in streams:
                    provider_name_clean = provider_name.replace("uhs_", "")
                    stream_name += "_alt_{0}".format(provider_name_clean)

                if provider_name.startswith("uhs_"):
                    stream = UHSStream(self.session, self.channel_id,
                                       self.url, provider_name,
                                       stream_index, password)
                elif (provider_url.startswith("rtmp") and
                      RTMPStream.is_usable(self.session)):
                        playpath = stream_info.get("streamName")
                        stream = self._create_rtmp_stream(provider_url,
                                                          playpath)

                if stream:
                    streams[stream_name] = stream

        return streams
开发者ID:3cky,项目名称:livestreamer,代码行数:53,代码来源:ustreamtv.py

示例10: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        self.logger.debug("Fetching stream info")
        res = urlget(self.url)

        match = re.search("var current_channel = (.*);", res.text)
        if match:
            json = parse_json(match.group(1))
        else:
            raise NoStreamsError(self.url)

        if not isinstance(json, dict):
            raise PluginError("Invalid JSON response")
        elif not "streams" in json:
            raise NoStreamsError(self.url)

        if not RTMPStream.is_usable(self.session):
            raise PluginError("rtmpdump is not usable and required by Filmon plugin")

        match = re.search("var flash_config = (.*);", res.text)
        if match:
            config = parse_json(match.group(1))
            if "streamer" in config:
                self.SWFURL = urljoin(self.SWFURL, config["streamer"])

        streams = {}

        for stream in json["streams"]:
            if not ("url" in stream and "name" in stream):
                continue

            parsed = urlparse(stream["url"])

            if not parsed.scheme.startswith("rtmp"):
                continue

            if parsed.query:
                app = "{0}?{1}".format(parsed.path[1:], parsed.query)
            else:
                app = parsed.path[1:]

            name = stream["quality"]
            streams[name] = RTMPStream(self.session, {
                "rtmp": stream["url"],
                "pageUrl": self.url,
                "swfUrl": self.SWFURL,
                "playpath": stream["name"],
                "app": app,
                "live": True
            })

        return streams
开发者ID:ncperry,项目名称:livestreamer,代码行数:53,代码来源:filmon.py

示例11: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        # If email option given, try to login
        if self.options.get("email"):
            res = http.get(self.LOGINPAGEURL)
            match = re.search('<meta content="([^"]+)" name="csrf-token"', res.text)
            if not match:
                raise PluginError("Missing CSRF Token: " + self.LOGINPAGEURL)
            csrf_token = match.group(1)

            email = self.options.get("email")
            password = self.options.get("password")

            res = http.post(
                self.LOGINPOSTURL,
                data={
                    "authenticity_token": csrf_token,
                    "channel_id": "",
                    "commit": "Login",
                    "plan_id": "",
                    "session[email]": email,
                    "session[password]": password,
                    "utf8": "\xE2\x9C\x93",  # Check Mark Character
                },
            )

            self.logger.debug("Login account info: {0}", res.text)
            result = http.json(res)
            if result.get("email", "no-mail") != email:
                raise PluginError("Invalid account")

        res = http.get(self.url)

        streams = {}

        if RTMPStream.is_usable(self.session):
            try:
                rtmpstreams = self._get_rtmp_streams(res.text)
                streams.update(rtmpstreams)
            except PluginError as err:
                self.logger.error("Error when fetching RTMP stream info: {0}", str(err))
        else:
            self.logger.warning("rtmpdump is not usable, only HLS streams will be available")

        try:
            hlsstreams = self._get_hls_streams(res.text)
            streams.update(hlsstreams)
        except PluginError as err:
            self.logger.error("Error when fetching HLS stream info: {0}", str(err))

        return streams
开发者ID:JamesHarperl,项目名称:livestreamer,代码行数:52,代码来源:livestation.py

示例12: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
 def _get_streams(self):
     params = parse_qsd(urlparse(self.url).query)
     if not 'watch' in params:
         raise NoStreamsError(self.url)
     channel = params['watch']
     
     if not RTMPStream.is_usable(self.session):
         raise PluginError("rtmpdump is not usable but required by Picarto plugin")
     
     streams = {}
     streams["live"] = RTMPStream(self.session, {
         "rtmp": "rtmp://199.189.86.17/dsapp/{0}.flv".format(channel),
         "pageUrl": self.url,
         "live": True
     })
     return streams
开发者ID:3cky,项目名称:livestreamer,代码行数:18,代码来源:picarto.py

示例13: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        country_code = urlparse(self.url).netloc.split(".")[0]

        self.logger.debug("Fetching stream info")
        res = http.get(self.APIURL)
        json = http.json(res)

        if not isinstance(json, dict):
            raise PluginError("Invalid JSON response")
        elif not ("primary" in json or "secondary" in json):
            raise PluginError("Invalid JSON response")

        if not RTMPStream.is_usable(self.session):
            raise PluginError("rtmpdump is not usable and required by Euronews plugin")

        streams = {}

        self.logger.debug("Euronews Countries:{0}", " ".join(json["primary"].keys()))

        if not (country_code in json["primary"] or country_code in json["secondary"]):
            res = http.get(self.GEOIPURL)
            geo = http.json(res)
            if isinstance(json, dict) and "country_code" in geo:
                country_code = geo["country_code"].lower()
                if not (country_code in json["primary"] or country_code in json["secondary"]):
                    country_code = "en"
            else:
                country_code = "en"

        for site in ("primary", "secondary"):
            for quality in json[site][country_code]["rtmp_flash"]:
                stream = json[site][country_code]["rtmp_flash"][quality]
                name = quality + "k"
                if site == "secondary":
                    name += "_alt"
                streams[name] = RTMPStream(self.session, {
                    "rtmp": stream["server"],
                    "playpath" : stream["name"],
                    "swfUrl": self.SWFURL,
                    "live": True
                })

        if len(streams) == 0:
            raise NoStreamsError(self.url)

        return streams
开发者ID:3cky,项目名称:livestreamer,代码行数:48,代码来源:euronews.py

示例14: _get_streams_from_amf

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams_from_amf(self):
        if not RTMPStream.is_usable(self.session):
            raise NoStreamsError(self.url)

        res = urlget(AMF_URL.format(self.channel_id))

        try:
            packet = AMFPacket.deserialize(BytesIO(res.content))
        except (IOError, AMFError) as err:
            raise PluginError("Failed to parse AMF packet: {0}".format(err))

        for message in packet.messages:
            if message.target_uri == "/1/onResult":
                result = message.value
                break
        else:
            raise PluginError("No result found in AMF packet")

        streams = {}
        stream_name = result.get("streamName")
        if stream_name:
            cdn = result.get("cdnUrl") or result.get("fmsUrl")
            if cdn:
                stream = self._create_rtmp_stream(cdn, stream_name)

                if "videoCodec" in result and result["videoCodec"]["height"] > 0:
                    stream_name = "{0}p".format(int(result["videoCodec"]["height"]))
                else:
                    stream_name = "live"

                streams[stream_name] = stream
            else:
                self.logger.warning("Missing cdnUrl and fmsUrl from result")

        stream_versions = result.get("streamVersions")
        if stream_versions:
            for version, info in stream_versions.items():
                stream_version_cdn = info.get("streamVersionCdn", {})

                for name, cdn in filter(valid_cdn, stream_version_cdn.items()):
                    stream = self._create_rtmp_stream(cdn["cdnStreamUrl"],
                                                      cdn["cdnStreamName"])
                    stream_name = "live_alt_{0}".format(name)
                    streams[stream_name] = stream

        return streams
开发者ID:alletti,项目名称:livestreamer,代码行数:48,代码来源:ustreamtv.py

示例15: _get_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import is_usable [as 别名]
    def _get_streams(self):
        match = re.search("/v/(\d+)", self.url)
        if not match:
            return

        vid = match.group(1)
        params = dict(client_name="Bambuser AS2", context="b_broadcastpage",
                      raw_user_input=1, api_key="005f64509e19a868399060af746a00aa",
                      vid=vid, r=random.random())

        self.logger.debug("Fetching stream info")
        res = http.get(PLAYER_URL, params=params)
        json = http.json(res)

        error = json and json.get("errorCode")
        if error:
            error = error and json.get("error")
            self.logger.error(error)
            return

        json = verifyjson(json, "result")
        playpath = verifyjson(json, "id")
        url = verifyjson(json, "url")
        (width, height) = verifyjson(json, "size").split("x")
        name = "{0}p".format(height)

        parsed = urlparse(url)
        streams  = {}

        if parsed.scheme.startswith("rtmp"):
            if not RTMPStream.is_usable(self.session):
                raise PluginError("rtmpdump is not usable and required by Bambuser plugin")
            streams[name] = RTMPStream(self.session, {
                "rtmp": url,
                "playpath": playpath,
                "pageUrl": self.url,
                "live": True
            })
        elif parsed.scheme == "http":
            streams[name] = HTTPStream(self.session, url)

        return streams
开发者ID:3cky,项目名称:livestreamer,代码行数:44,代码来源:bambuser.py


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