예제 #1
0
 def test_rtmpparse(self):
     self.assertEqual(("rtmp://testserver.com:1935/app", "playpath?arg=1"),
                      rtmpparse("rtmp://testserver.com/app/playpath?arg=1"))
     self.assertEqual(
         ("rtmp://testserver.com:1935/long/app", "playpath?arg=1"),
         rtmpparse("rtmp://testserver.com/long/app/playpath?arg=1"))
     self.assertEqual(("rtmp://testserver.com:1935/app", None),
                      rtmpparse("rtmp://testserver.com/app"))
예제 #2
0
 def test_rtmpparse(self):
     self.assertEqual(
         ("rtmp://testserver.com:1935/app", "playpath?arg=1"),
         rtmpparse("rtmp://testserver.com/app/playpath?arg=1"))
     self.assertEqual(
         ("rtmp://testserver.com:1935/long/app", "playpath?arg=1"),
         rtmpparse("rtmp://testserver.com/long/app/playpath?arg=1"))
     self.assertEqual(
         ("rtmp://testserver.com:1935/app", None),
         rtmpparse("rtmp://testserver.com/app"))
예제 #3
0
    def _create_rtmp_stream(self, video):
        name, stream_url = video
        params = {
            "rtmp": stream_url,
            "pageUrl": self.url,
            "swfVfy": self._get_swf_url(),
        }

        if stream_url.endswith(".mp4"):
            tcurl, playpath = rtmpparse(stream_url)
            params["rtmp"] = tcurl
            params["playpath"] = playpath
        else:
            params["live"] = True

        return name, RTMPStream(self.session, params)
예제 #4
0
    def _create_rtmp_stream(self, video):
        name, stream_url = video
        params = {
            "rtmp": stream_url,
            "pageUrl": self.url,
            "swfVfy": self._get_swf_url(),
        }

        if stream_url.endswith(".mp4"):
            tcurl, playpath = rtmpparse(stream_url)
            params["rtmp"] = tcurl
            params["playpath"] = playpath
        else:
            params["live"] = True

        return name, RTMPStream(self.session, params)
예제 #5
0
    def _get_rtmp_stream(self, swfurl):
        res = http.get(swfurl)
        swf = swfdecompress(res.content)
        match = _rtmp_re.search(swf)
        if not match:
            return

        res = http.get(match.group(1))
        rtmp, playpath = rtmpparse(res.text)
        params = {
            "rtmp": rtmp,
            "pageUrl": self.url,
            "playpath": playpath,
            "swfUrl": swfurl,
            "live": True
        }

        return RTMPStream(self.session, params)
예제 #6
0
    def _get_rtmp_stream(self, swfurl):
        res = http.get(swfurl)
        swf = swfdecompress(res.content)
        match = _rtmp_re.search(swf)
        if not match:
            return

        res = http.get(match.group(1))
        rtmp, playpath = rtmpparse(res.text)
        params = {
            "rtmp": rtmp,
            "pageUrl": self.url,
            "playpath": playpath,
            "swfUrl": swfurl,
            "live": True
        }

        return RTMPStream(self.session, params)
예제 #7
0
    def _update_redirect(self, stderr):
        tcurl, redirect = None, None
        stderr = str(stderr, "utf8")

        m = re.search(r"DEBUG: Property: <Name:\s+redirect,\s+STRING:\s+(\w+://.+?)>", stderr)
        if m:
            redirect = m.group(1)

        if redirect:
            log.debug("Found redirect tcUrl: {0}", redirect)

            if "rtmp" in self.parameters:
                tcurl, playpath = rtmpparse(self.parameters["rtmp"])
                if playpath:
                    rtmp = "{redirect}/{playpath}".format(redirect=redirect, playpath=playpath)
                else:
                    rtmp = redirect
                self.parameters["rtmp"] = rtmp

            if "tcUrl" in self.parameters:
                self.parameters["tcUrl"] = redirect
예제 #8
0
    def _update_redirect(self, stderr):
        tcurl, redirect = None, None
        stderr = str(stderr, "utf8")

        m = re.search(r"DEBUG: Property: <Name:\s+redirect,\s+STRING:\s+(\w+://.+?)>", stderr)
        if m:
            redirect = m.group(1)

        if redirect:
            log.debug("Found redirect tcUrl: {0}", redirect)

            if "rtmp" in self.parameters:
                tcurl, playpath = rtmpparse(self.parameters["rtmp"])
                if playpath:
                    rtmp = "{redirect}/{playpath}".format(redirect=redirect, playpath=playpath)
                else:
                    rtmp = redirect
                self.parameters["rtmp"] = rtmp

            if "tcUrl" in self.parameters:
                self.parameters["tcUrl"] = redirect