Esempio n. 1
0
    def _get_live_streams(self):
        stream_id = _id_map[self.channel_path]

        if stream_id == "ruv":
            qualities_rtmp = ["720p", "480p", "360p", "240p"]

            for i, quality in enumerate(qualities_rtmp):
                yield quality, RTMPStream(
                    self.session, {
                        "rtmp": RTMP_LIVE_URL.format(stream_id, i + 1),
                        "pageUrl": self.url,
                        "live": True
                    })

            qualities_hls = ["240p", "360p", "480p", "720p"]
            for i, quality_hls in enumerate(qualities_hls):
                yield quality_hls, HLSStream(self.session,
                                             HLS_RUV_LIVE_URL.format(i + 1))

        else:
            yield "audio", RTMPStream(
                self.session, {
                    "rtmp": RTMP_LIVE_URL.format(stream_id, 1),
                    "pageUrl": self.url,
                    "live": True
                })

            yield "audio", HLSStream(self.session,
                                     HLS_RADIO_LIVE_URL.format(stream_id))
Esempio n. 2
0
    def _get_streams(self):
        page = http.get(self.url)

        try:
            channel, _, _, _, online, visibility, is_flash = self._get_stream_arguments(
                page)
        except ValueError:
            return

        if not online:
            self.logger.error("This stream is currently offline")
            return

        channel_server_res = http.post(API_CHANNEL_INFO,
                                       data={"loadbalancinginfo": channel})

        if is_flash:
            return {
                "live":
                RTMPStream(
                    self.session, {
                        "rtmp": RTMP_URL.format(channel_server_res.text),
                        "playpath": RTMP_PLAYPATH.format(channel, visibility),
                        "pageUrl": self.url,
                        "live": True
                    })
            }
        else:
            return HLSStream.parse_variant_playlist(
                self.session,
                HLS_URL.format(channel_server_res.text, channel, visibility),
                verify=False)
Esempio n. 3
0
    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)
Esempio n. 4
0
    def _create_stream(self, stream, is_live):
        stream_name = "{0}p".format(stream["height"])
        stream_type = stream["mediaType"]
        stream_url = stream["url"]

        if stream_type in ("hls", "mp4"):
            if urlparse(stream_url).path.endswith("m3u8"):
                try:
                    streams = HLSStream.parse_variant_playlist(
                        self.session, stream_url)

                    # TODO: Replace with "yield from" when dropping Python 2.
                    for stream in streams.items():
                        yield stream
                except IOError as err:
                    self.logger.error("Failed to extract HLS streams: {0}",
                                      err)
            else:
                yield stream_name, HTTPStream(self.session, stream_url)

        elif stream_type == "rtmp":
            params = {
                "rtmp": stream["streamer"],
                "playpath": stream["url"],
                "swfVfy": SWF_URL,
                "pageUrl": self.url,
            }

            if is_live:
                params["live"] = True
            else:
                params["playpath"] = "mp4:{0}".format(params["playpath"])

            stream = RTMPStream(self.session, params)
            yield stream_name, stream
Esempio n. 5
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        video_id = match.group("video_id")
        res = http.get(ASSET_URL.format(video_id))
        assets = http.xml(res, schema=_asset_schema)

        streams = {}
        for asset in assets:
            base = asset["base"]
            url = asset["url"]

            if urlparse(url).path.endswith(".f4m"):
                streams.update(
                    HDSStream.parse_manifest(self.session, url, pvswf=SWF_URL)
                )
            elif base.startswith("rtmp"):
                name = "{0}k".format(asset["bitrate"])
                params = {
                    "rtmp": asset["base"],
                    "playpath": url,
                    "live": True
                }
                streams[name] = RTMPStream(self.session, params)

        return streams
Esempio n. 6
0
    def _get_sarpurinn_streams(self):
        res = http.get(self.url)
        match = _rtmp_url_re.search(res.text)

        if not match:
            yield

        token = match.group("id")
        status = match.group("status")
        extension = match.group("ext")
        date = match.group("date")
        if not date:
            date = ""

        if extension == "mp3":
            key = "audio"
        else:
            key = "576p"

            # HLS on Sarpurinn is currently only available on videos
            yield key, HLSStream(
                self.session,
                HLS_SARPURINN_URL.format(status, date, token, extension))

        yield key, RTMPStream(
            self.session, {
                "rtmp": RTMP_SARPURINN_URL.format(status, date, token,
                                                  extension),
                "pageUrl": self.url,
                "live": True
            })
Esempio n. 7
0
    def _get_live_streams(self, params, swf_url):
        for key, quality in QUALITY_MAP.items():
            key_url = "{0}URL".format(key)
            url = params.get(key_url)

            if not url:
                continue

            try:
                res = http.get(url, exception=IOError)
            except IOError:
                continue

            if quality == "hds":
                streams = HDSStream.parse_manifest(self.session, res.url)
                for name, stream in streams.items():
                    if key == "source":
                        name += "+"

                    yield name, stream
            elif res.text.startswith("rtmp"):
                match = _rtmp_re.match(res.text)
                if not match:
                    continue

                stream = RTMPStream(
                    self.session, {
                        "rtmp": match.group("host"),
                        "app": match.group("app"),
                        "playpath": match.group("playpath"),
                        "swfVfy": swf_url,
                        "live": True
                    })

                yield quality, stream
Esempio n. 8
0
 def _create_rtmp_stream(self, rtmp, playpath, live):
     return RTMPStream(
         self.session, {
             "rtmp": rtmp,
             "playpath": playpath,
             "pageUrl": self.url,
             "swfVfy": SWF_URL,
             "live": live
         })
Esempio n. 9
0
 def _get_streams(self):
     res = http.get(self.url)
     match = _streams_re.findall(res.content.decode('utf-8'))
     for url, stream_type in match:
         if stream_type == "rtmp/mp4" and RTMPStream.is_usable(
                 self.session):
             params = {
                 "rtmp": url,
                 "pageUrl": self.url,
                 "live": True,
             }
             yield 'live', RTMPStream(self.session, params)
         elif stream_type == "application/x-mpegURL":
             for s in HLSStream.parse_variant_playlist(self.session,
                                                       url).items():
                 yield s
         elif stream_type == "video/mp4":
             yield 'vod', HTTPStream(self.session, url)
Esempio n. 10
0
    def _get_streams(self):
        url_match = _url_re.match(self.url)
        stream_url = _stream_url.format(channel=url_match.group(1))
        res = self.session.http.get(stream_url)
        match = _stream_re.search(res.text)
        if match:
            params = dict(rtmp="rtmp://stream.connectcast.tv/live",
                          playpath=match.group(1),
                          live=True)

            return dict(live=RTMPStream(self.session, params))
Esempio n. 11
0
 def _get_rtmp_streams(self, info):
     name = QUALITY_MAP.get(info["_quality"], "live")
     params = {
         "rtmp": info["_server"].strip(),
         "playpath": info["_stream"],
         "pageUrl": self.url,
         "swfVfy": SWF_URL,
         "live": True
     }
     stream = RTMPStream(self.session, params)
     yield name, stream
Esempio n. 12
0
    def _get_streams(self):
        stream_url = http.get(self.url, schema=_schema)
        if not stream_url:
            return

        stream = RTMPStream(self.session, {
            "rtmp": stream_url,
            "pageUrl": self.url,
            "live": True
        })

        return dict(live=stream)
Esempio n. 13
0
    def _create_rtmp_stream(self, cdn, stream_name):
        parsed = urlparse(cdn)
        params = {
            "rtmp": cdn,
            "app": parsed.path[1:],
            "playpath": stream_name,
            "pageUrl": self.url,
            "swfUrl": SWF_URL,
            "live": True
        }

        return RTMPStream(self.session, params)
Esempio n. 14
0
    def _get_streams(self):
        res = http.get(self.url)

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

        xml_info_url = STREAMS_INFO_URL.format(match.group(1))
        video_info_res = http.get(xml_info_url)
        parsed_info = http.xml(video_info_res)

        live_el = parsed_info.find("live")
        live = live_el is not None and live_el.text == "1"

        streams = {}

        hdsurl_el = parsed_info.find("hdsurl")
        if hdsurl_el is not None and hdsurl_el.text is not None:
            hdsurl = hdsurl_el.text
            streams.update(HDSStream.parse_manifest(self.session, hdsurl))

        if live:
            vurls_el = parsed_info.find("vurls")
            if vurls_el is not None:
                for i, vurl_el in enumerate(vurls_el):
                    bitrate = vurl_el.get("bitrate")
                    name = bitrate + "k" if bitrate is not None else "rtmp{0}".format(
                        i)
                    params = {
                        "rtmp": vurl_el.text,
                    }
                    streams[name] = RTMPStream(self.session, params)

        parsed_urls = set()
        mobileurls_el = parsed_info.find("mobileurls")
        if mobileurls_el is not None:
            for mobileurl_el in mobileurls_el:
                text = mobileurl_el.text
                if not text:
                    continue

                if text in parsed_urls:
                    continue

                parsed_urls.add(text)
                url = urlparse(text)

                if url[0] == "http" and url[2].endswith("m3u8"):
                    streams.update(
                        HLSStream.parse_variant_playlist(self.session, text))

        return streams
Esempio n. 15
0
    def _create_rtmp_stream(self, rtmp, swf_url, bitrate):
        quality = self._get_quality(bitrate["label"])
        url = bitrate["url"]
        stream = RTMPStream(
            self.session, {
                "rtmp": rtmp,
                "pageUrl": self.url,
                "playpath": url,
                "swfVfy": swf_url,
                "live": True
            })

        return quality, stream
Esempio n. 16
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        channel_name = match.group("channel")

        form = {
            "cid": channel_name,
            "watchTime": 0,
            "firstConnect": 1,
            "ip": "NaN"
        }
        res = http.post(API_URL, data=form, headers=HEADERS)
        params = parse_query(res.text, schema=_schema)

        if params["status"] <= 0:
            return

        if params["block_type"] != 0:
            if params["block_type"] == BLOCK_TYPE_VIEWING_LIMIT:
                msg = BLOCKED_MSG_FORMAT.format(
                    params.get("block_time", "UNKNOWN"),
                    params.get("reconnect_time", "UNKNOWN"))
                raise PluginError(msg)
            elif params["block_type"] == BLOCK_TYPE_NO_SLOTS:
                raise PluginError("No free slots available")
            else:
                raise PluginError("Blocked for unknown reasons")

        if "token" not in params:
            raise PluginError("Server seems busy, retry again later")

        streams = {}
        stream_names = ["sd"]
        if params["multibitrate"]:
            stream_names += ["hd"]

        for stream_name in stream_names:
            playpath = params["playpath"]
            if stream_name == "hd":
                playpath += "HI"

            stream = RTMPStream(
                self.session, {
                    "rtmp": "{0}/{1}".format(params["rtmp"], playpath),
                    "pageUrl": self.url,
                    "swfVfy": SWF_URL,
                    "weeb": params["token"],
                    "live": True
                })
            streams[stream_name] = stream

        return streams
Esempio n. 17
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        channel = match.group("channel")

        streamurl = getStreamURL(channel)
        if not streamurl:
            return
        streams = {}
        streams["live"] = RTMPStream(self.session, {
            "rtmp": streamurl,
            "live": True
        })

        return streams
Esempio n. 18
0
 def _get_plu_streams(self, cid):
     res = http.get(PLU_STREAM_INFO_URL % cid)
     info = http.json(res, schema=_plu_schema)
     for source in info["urls"]:
         quality = self._get_quality(source["resolution"])
         if source["ext"] == "m3u8":
             yield quality, HLSStream(self.session, source["securityUrl"])
         elif source["ext"] == "flv":
             yield quality, HTTPStream(self.session, source["securityUrl"])
         elif source["ext"] == "rtmp":
             yield quality, RTMPStream(self.session, {
                 "rtmp": source["securityUrl"],
                 "live": True
             })
    def _get_rtmp_stream(self, channel_name):
        params = {
            "l": "info",
            "a": "xmlClipPath",
            "clip_id": channel_name,
            "rid": time()
        }
        res = http.get(API_URL, params=params)
        rtmp_url = http.xml(res, schema=_rtmp_schema)

        return RTMPStream(self.session, {
            "rtmp": rtmp_url,
            "swfVfy": SWF_URL,
            "live": True
        })
Esempio n. 20
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)
Esempio n. 21
0
    def _create_rtmp_stream(self, url):
        parsed = urlparse(url)
        if parsed.query:
            app = "{0}?{1}".format(parsed.path[1:], parsed.query)
        else:
            app = parsed.path[1:]

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

        stream = RTMPStream(self.session, params)
        return "live", stream
Esempio n. 22
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        info = http.get(PLAYER_URL, params=match.groupdict(), schema=_schema)
        if not info["path"]:
            return

        app, playpath = info["path"]
        stream = RTMPStream(
            self.session, {
                "rtmp": "rtmp://{0}/{1}".format(info["server_ip"], app),
                "playpath": playpath,
                "pageUrl": self.url,
                "swfUrl": SWF_URL,
                "live": True
            })

        return dict(live=stream)
Esempio n. 23
0
    def _get_streams(self):
        res = http.get(self.url, schema=_schema)
        streams = {}
        for url in res["urls"]:
            parsed = urlparse(url)
            if parsed.scheme.startswith("rtmp"):
                params = {"rtmp": url, "pageUrl": self.url, "live": True}
                if res["swf"]:
                    params["swfVfy"] = res["swf"]

                stream = RTMPStream(self.session, params)
                streams["live"] = stream
            elif parsed.scheme.startswith("http"):
                name = splitext(parsed.path)[1][1:]
                stream = HTTPStream(self.session, url)
                streams[name] = stream

        return streams
Esempio n. 24
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)
Esempio n. 25
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        video_id = match.group("video_id")
        channel = match.group("channel")

        if video_id:
            return self._get_playlist(vod=video_id)
        elif channel:
            return {
                'live':
                RTMPStream(
                    self.session,
                    dict(rtmp=LIVE_STREAM_URL,
                         app="live",
                         pageUrl=self.url,
                         playpath=channel,
                         live=True))
            }
Esempio n. 26
0
    def _get_playlist(self, **params):
        res = http.get(PLAYLIST_URL, params=params)
        playlist = http.xml(res, schema=_playlist_schema)
        streams = {}
        for video in playlist["videos"]:
            name = "{0}p".format(video["height"])
            stream = RTMPStream(
                self.session, {
                    "rtmp": "{0}/{1}".format(playlist["base"], video["src"]),
                    "app": urlparse(playlist["base"]).path[1:],
                    "pageUrl": self.url,
                    "rtmp": playlist["base"],
                    "playpath": video["src"],
                    "live": True
                })
            streams[name] = stream

        return streams
Esempio n. 27
0
    def _get_streams(self):
        res = self.url
        streamname = _url_re.search(res).group(1)
        streams = {}
        stream = RTMPStream(
            self.session, {
                "rtmp": ROOT_URL.format(streamname),
                "pageUrl": PAGE_URL,
                "live": True,
                "app": "live",
                "flashVer": "LNX 11,2,202,280",
                "swfVfy":
                "https://www.tigerdile.com/wp-content/jwplayer.flash.swf",
                "playpath": streamname,
            })
        streams["live"] = stream

        return streams
Esempio n. 28
0
    def _get_streams(self):
        res = http.get(self.url)
        match = _swf_player_re.search(res.text)
        if match is None:
            return
        swfUrl = "http://vaughnlive.tv" + match.group(1)

        match = _url_re.match(self.url)
        params = {}
        params["channel"] = match.group("channel").lower()
        params["domain"] = DOMAIN_MAP.get(match.group("domain"),
                                          match.group("domain"))
        params["version"] = PLAYER_VERSION
        params["ms"] = random.randint(0, 999)
        params["random"] = random.random()
        info = http.get(INFO_URL.format(**params), schema=_schema)

        app = "live"
        if info["server"] in [
                "198.255.17.18:1337", "198.255.17.66:1337", "50.7.188.2:1337"
        ]:
            if info["ingest"] == "SJC":
                app = "live-sjc"
            elif info["ingest"] == "NYC":
                app = "live-nyc"
            elif info["ingest"] == "ORD":
                app = "live-ord"
            elif info["ingest"] == "AMS":
                app = "live-ams"
            elif info["ingest"] == "DEN":
                app = "live-den"

        stream = RTMPStream(
            self.session, {
                "rtmp": "rtmp://{0}/live".format(info["server"]),
                "app": "{0}?{1}".format(app, info["token"]),
                "swfVfy": swfUrl,
                "pageUrl": self.url,
                "live": True,
                "playpath": "{domain}_{channel}".format(**params),
            })

        return dict(live=stream)
Esempio n. 29
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        channel = match.group("channel")
        res = http.get(CHANNEL_INFO.format(channel))
        channel_info = http.json(res)

        if not channel_info["online"]:
            return

        res = http.get(CHANNEL_MANIFEST.format(channel_info["id"]))
        assets = http.xml(res, schema=_assets_schema)
        streams = {}
        for video in assets["videos"]:
            name = "{0}p".format(video["height"])
            stream = RTMPStream(
                self.session,
                {"rtmp": "{0}/{1}".format(assets["base"], video["src"])})
            streams[name] = stream

        return streams
Esempio n. 30
0
    def _get_streams(self):
        match = _url_re.match(self.url)
        if not match:
            return

        channel_name = match.group(1)

        res = http.get(STREAMS_URL.format(channel_name))
        streams = http.json(res, schema=_streams_schema)
        if streams["type"] not in ("multi", "stream"):
            return

        for stream in streams["data"]:
            if stream["slug"] != channel_name:
                continue

            if not stream["live"]:
                return

            streams = {}

            try:
                streams.update(
                    HLSStream.parse_variant_playlist(
                        self.session, HLS_URL.format(stream["id"])))
            except IOError as e:
                # fix for hosted offline streams
                if "404 Client Error" in str(e):
                    return
                raise

            streams["rtmp"] = RTMPStream(
                self.session, {
                    "rtmp": RTMP_URL.format(stream["id"]),
                    "pageUrl": self.url,
                    "live": True
                })

            return streams

        return