Esempio n. 1
0
    def _get_rtmp_streams(self, channelname):
        options = dict(l="info",
                       a="xmlClipPath",
                       clip_id=channelname,
                       rid=time())
        res = urlget(self.APIURL, params=options)

        dom = res_xml(res)
        rtmpurl = dom.getElementsByTagName("url")
        rtmp = None

        if len(rtmpurl) > 0:
            rtmp = get_node_text(rtmpurl[0])
        else:
            raise PluginError(
                ("No RTMP Streams found on URL {0}").format(self.url))

        rtmplist = {}
        rtmplist["live"] = RTMPStream(self.session, {
            "rtmp": rtmp,
            "swfVfy": self.SWFURL,
            "live": True
        })

        return rtmplist
Esempio n. 2
0
    def _limelight_soap_playlist_items(self, channelid):
        payload = """<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                                         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                       <SOAP-ENV:Body>
                         <tns:getPlaylistWithNItemsByChannelId xmlns:tns="http://service.data.media.pluggd.com">
                           <tns:in0>{0}</tns:in0>
                           <tns:in1>0</tns:in1>
                           <tns:in2>7</tns:in2>
                         </tns:getPlaylistWithNItemsByChannelId>
                       </SOAP-ENV:Body>
                     </SOAP-ENV:Envelope>""".format(channelid)

        headers = {
            "Content-Type": "text/xml; charset=utf-8",
            "Referer": "http://assets.delvenetworks.com/player/loader.swf",
            "x-page-url": self.url
        }

        res = urlopen(self.LimelightSOAPURL, data=payload, headers=headers)
        dom = res_xml(res)

        streams = {}
        for item in dom.getElementsByTagName("PlaylistItem"):
            for stream in dom.getElementsByTagName("Stream"):
                for url in stream.getElementsByTagName("url"):
                    url = get_node_text(url)
                    break
                else:
                    continue

                for height in stream.getElementsByTagName(
                        "videoHeightInPixels"):
                    height = get_node_text(height)
                    break
                else:
                    continue

                streamname = "{0}p".format(height)
                parsed = urlparse(url)

                if parsed.scheme.startswith("rtmp"):
                    params = dict(rtmp=url, live=True)
                    streams[streamname] = RTMPStream(self.session, params)

        return streams
Esempio n. 3
0
    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 = {}

        dom = parse_xml(data, "config XML")
        nodes = dom.getElementsByTagName("nodes")[0]

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

        swfurl = urlresolve(self.SWFURL)
        if "?" in swfurl:
            swfurl = swfurl[:swfurl.find("?")]

        for node in nodes.childNodes:
            info = {}
            for child in node.childNodes:
                info[child.tagName] = 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
Esempio n. 4
0
    def _limelight_soap_playlist_items(self, channelid):
        payload = """<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                                         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                       <SOAP-ENV:Body>
                         <tns:getPlaylistWithNItemsByChannelId xmlns:tns="http://service.data.media.pluggd.com">
                           <tns:in0>{0}</tns:in0>
                           <tns:in1>0</tns:in1>
                           <tns:in2>7</tns:in2>
                         </tns:getPlaylistWithNItemsByChannelId>
                       </SOAP-ENV:Body>
                     </SOAP-ENV:Envelope>""".format(channelid)

        headers = {
            "Content-Type": "text/xml; charset=utf-8",
            "Referer": "http://assets.delvenetworks.com/player/loader.swf",
            "x-page-url": self.url
        }

        res = urlopen(self.LimelightSOAPURL, data=payload, headers=headers)
        dom = res_xml(res)

        streams = {}
        for item in dom.getElementsByTagName("PlaylistItem"):
            for stream in dom.getElementsByTagName("Stream"):
                for url in stream.getElementsByTagName("url"):
                    url = get_node_text(url)
                    break
                else:
                    continue

                for height in stream.getElementsByTagName("videoHeightInPixels"):
                    height = get_node_text(height)
                    break
                else:
                    continue

                streamname = "{0}p".format(height)
                parsed = urlparse(url)

                if parsed.scheme.startswith("rtmp"):
                    params = dict(rtmp=url, live=True)
                    streams[streamname] = RTMPStream(self.session, params)

        return streams
Esempio n. 5
0
    def _is_live(self, liveid):
        res = urlget(self.StatusAPIURL.format(liveid))

        dom = res_xml(res, "status XML")

        live = dom.getElementsByTagName("live_is_live")

        if len(live) > 0:
            return get_node_text(live[0]) == "1"

        return False
    def _get_rtmp_streams(self, channelname):
        options = dict(l="info", a="xmlClipPath", clip_id=channelname,
                       rid=time())
        res = urlget(self.APIURL, params=options)

        dom = res_xml(res)
        rtmpurl = dom.getElementsByTagName("url")
        rtmp = None

        if len(rtmpurl) > 0:
            rtmp = get_node_text(rtmpurl[0])
        else:
            raise PluginError(("No RTMP Streams found on URL {0}").format(self.url))

        rtmplist = {}
        rtmplist["live"] = RTMPStream(self.session, {
            "rtmp": rtmp,
            "swfVfy": self.SWFURL,
            "live": True
        })

        return rtmplist
Esempio n. 7
0
    def _parse_gox_file(self, data):
        dom = parse_xml(data, "GOX XML")
        entries = []

        for xentry in dom.getElementsByTagName("ENTRY"):
            entry = {}
            for child in xentry.childNodes:
                if isinstance(child, xml.dom.minidom.Element):
                    if child.tagName == "REF":
                        href = child.getAttribute("href")

                        # SQ and SQTest streams can be gomp2p links, with actual stream address passed as a parameter.
                        if href.startswith("gomp2p://"):
                            href, n = re.subn("^.*LiveAddr=", "", href)
                            href = unquote(href)

                        entry[child.tagName] = href
                    else:
                        entry[child.tagName] = get_node_text(child)

            entries.append(entry)

        return entries
Esempio n. 8
0
    def _parse(self, dom):
        for child in dom.childNodes:
            if isinstance(child, xml.dom.minidom.Element):
                if child.tagName == "REF":
                    href = child.getAttribute("href")

                    if child.hasAttribute("reftype"):
                        reftype = child.getAttribute("reftype")
                    else:
                        reftype = None

                    # Streams can be gomp2p links, with actual stream
                    # URL passed as a parameter
                    if href.startswith("gomp2p://"):
                        href, n = re.subn("^.*LiveAddr=", "", href)
                        href = unquote(href)

                    href = href.replace("&amp;", "&")
                    val = (href, reftype)
                else:
                    val = get_node_text(child)

                attr = child.tagName.lower()
                setattr(self, attr, val)
Esempio n. 9
0
    def _parse(self, dom):
        for child in dom.childNodes:
            if isinstance(child, xml.dom.minidom.Element):
                if child.tagName == "REF":
                    href = child.getAttribute("href")

                    if child.hasAttribute("reftype"):
                        reftype = child.getAttribute("reftype")
                    else:
                        reftype = None

                    # Streams can be gomp2p links, with actual stream
                    # URL passed as a parameter
                    if href.startswith("gomp2p://"):
                        href, n = re.subn("^.*LiveAddr=", "", href)
                        href = unquote(href)

                    href = href.replace("&amp;", "&")
                    val = (href, reftype)
                else:
                    val = get_node_text(child)

                attr = child.tagName.lower()
                setattr(self, attr, val)
Esempio n. 10
0
 def _get_node_if_exists(self, dom, name):
     elements = dom.getElementsByTagName(name)
     if elements and len(elements) > 0:
         return get_node_text(elements[0])
Esempio n. 11
0
 def _get_node_if_exists(self, dom, name):
     elements = dom.getElementsByTagName(name)
     if elements and len(elements) > 0:
         return get_node_text(elements[0])