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


Python RTMPStream.params["jtv"]方法代码示例

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


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

示例1: _get_rtmp_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import params["jtv"] [as 别名]
    def _get_rtmp_streams(self):
        def clean_tag(tag):
            if tag[0] == "_":
                return tag[1:]
            else:
                return tag

        chansub = self._authenticate()

        url = self.StreamInfoURL.format(self.channelname)
        params = dict(b_id="true", group="", private_code="null",
                      p=int(random.random() * 999999),
                      channel_subscription=chansub, type="any")

        self.logger.debug("Fetching stream info")
        res = urlget(url, params=params)
        data = res.text

        # fix invalid xml
        data = re.sub("<(\d+)", "<_\g<1>", data)
        data = re.sub("</(\d+)", "</_\g<1>", data)

        streams = {}

        try:
            dom = xml.dom.minidom.parseString(data)
        except Exception as err:
            raise PluginError(("Unable to parse config XML: {0})").format(err))

        nodes = dom.getElementsByTagName("nodes")[0]

        if len(nodes.childNodes) == 0:
            return streams

        swfurl = urlresolve(self.SWFURL)

        for node in nodes.childNodes:
            info = {}
            for child in node.childNodes:
                info[child.tagName] = self._get_node_text(child)

            if not ("connect" in info and "play" in info):
                continue

            stream = RTMPStream(self.session, {
                "rtmp": ("{0}/{1}").format(info["connect"], info["play"]),
                "swfVfy": swfurl,
                "live": True
            })

            sname = clean_tag(node.tagName)

            if "token" in info:
                stream.params["jtv"] = info["token"]
            else:
                self.logger.warning("No token found for stream {0}, this stream may fail to play", sname)

            streams[sname] = stream

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

示例2: _get_rtmp_streams

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import params["jtv"] [as 别名]
    def _get_rtmp_streams(self):
        chansub = self._authenticate()

        url = self.StreamInfoURL.format(self.channelname)
        params = dict(
            b_id="true",
            group="",
            private_code="null",
            p=int(random.random() * 999999),
            channel_subscription=chansub,
            type="any",
        )

        self.logger.debug("Fetching stream info")
        res = urlget(url, params=params)
        json = res_json(res, "stream info JSON")

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

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

        streams = {}
        swfurl, swfhash, swfsize = self._verify_swf()

        for info in json:
            if not ("connect" in info and "play" in info and "type" in info):

                continue

            stream = RTMPStream(
                self.session,
                {
                    "rtmp": ("{0}/{1}").format(info["connect"], info["play"]),
                    "swfUrl": swfurl,
                    "swfhash": swfhash,
                    "swfsize": swfsize,
                    "live": True,
                },
            )

            if "display" in info:
                sname = info["display"]
            else:
                sname = info["type"]

            if "token" in info:
                stream.params["jtv"] = info["token"]
            else:
                self.logger.warning("No token found for stream {0}, this stream may fail to play", sname)

            streams[sname] = stream

        return streams
开发者ID:hilalpro,项目名称:JTV-Livestreamer-video-unlocked,代码行数:57,代码来源:justintv.py

示例3: _get_streaminfo

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import params["jtv"] [as 别名]
    def _get_streaminfo(self, channelname):
        def clean_tag(tag):
            if tag[0] == "_":
                return tag[1:]
            else:
                return tag

        metadata = self._get_metadata(channelname)
        randomp = int(random.random() * 999999)

        if "chansub_guid" in metadata:
            url = self.StreamInfoURLSub.format(channelname, randomp, metadata["chansub_guid"])
        else:
            url = self.StreamInfoURL.format(channelname, randomp)

        data = urlget(url)

        # fix invalid xml
        data = re.sub(b"<(\d+)", b"<_\g<1>", data)
        data = re.sub(b"</(\d+)", b"</_\g<1>", data)

        streams = {}

        try:
            dom = xml.dom.minidom.parseString(data)
        except Exception as err:
            raise PluginError(("Unable to parse config XML: {0})").format(err))

        nodes = dom.getElementsByTagName("nodes")[0]

        swfhash, swfsize = swfverify(self.SWFURL)

        for node in nodes.childNodes:
            info = {}
            for child in node.childNodes:
                info[child.tagName] = self._get_node_text(child)

            stream = RTMPStream({
                "rtmp": ("{0}/{1}").format(info["connect"], info["play"]),
                "swfUrl": self.SWFURL,
                "swfhash": swfhash,
                "swfsize": swfsize,
                "live": 1
            })

            if "token" in info:
                stream.params["jtv"] = info["token"]

            sname = clean_tag(node.tagName)
            streams[sname] = stream

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

示例4: _get_streaminfo

# 需要导入模块: from livestreamer.stream import RTMPStream [as 别名]
# 或者: from livestreamer.stream.RTMPStream import params["jtv"] [as 别名]
    def _get_streaminfo(self, channelname):
        def clean_tag(tag):
            if tag[0] == "_":
                return tag[1:]
            else:
                return tag


        chansub = None
        if self.options.get("cookie") is not None:
            self.logger.debug("Attempting to authenticate using cookie")

            metadata = self._get_metadata(channelname)
            chansub = metadata["access_guid"]

            if "login" in metadata and metadata["login"] is not None:
                self.logger.debug("Successfully logged in as {0}", metadata["login"])


        randomp = int(random.random() * 999999)
        url = self.StreamInfoURL.format(channelname, randomp, chansub)

        self.logger.debug("Fetching stream info")
        data = urlget(url)

        # fix invalid xml
        data = re.sub(b"<(\d+)", b"<_\g<1>", data)
        data = re.sub(b"</(\d+)", b"</_\g<1>", data)

        streams = {}

        try:
            dom = xml.dom.minidom.parseString(data)
        except Exception as err:
            raise PluginError(("Unable to parse config XML: {0})").format(err))

        nodes = dom.getElementsByTagName("nodes")[0]

        self.logger.debug("Verifying SWF: {0}", self.SWFURL)
        swfhash, swfsize = swfverify(self.SWFURL)

        for node in nodes.childNodes:
            info = {}
            for child in node.childNodes:
                info[child.tagName] = self._get_node_text(child)

            stream = RTMPStream(self.session, {
                "rtmp": ("{0}/{1}").format(info["connect"], info["play"]),
                "swfUrl": self.SWFURL,
                "swfhash": swfhash,
                "swfsize": swfsize,
                "live": True
            })

            sname = clean_tag(node.tagName)

            if "token" in info:
                stream.params["jtv"] = info["token"]
            else:
                self.logger.warning("No token found for stream {0}, this stream may fail to play", sname)

            streams[sname] = stream

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


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