Exemplo n.º 1
0
    def _parse_stream_map(self, streammap):
        streams = []

        for stream_qs in streammap.split(","):
            stream = parse_qsd(stream_qs)
            streams.append(stream)

        return streams
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    def __init__(self, url):
        Plugin.__init__(self, url)

        try:
            match = re.match(URL_PATTERN, url).groupdict()
            self.channel = match.get("channel").lower()
            self.video_type = match.get("video_type")
            self.video_id = match.get("video_id")
            self.usher = UsherService(match.get("domain"))

            parsed = urlparse(url)
            self.params = parse_qsd(parsed.query)
        except AttributeError:
            self.channel = None
            self.params = None
            self.video_id = None
            self.video_type = None
            self.usher = None
Exemplo n.º 5
0
    def __init__(self, url):
        Plugin.__init__(self, url)

        try:
            match = re.match(URL_PATTERN, url).groupdict()
            self.channel = match.get("channel").lower()
            self.video_type = match.get("video_type")
            self.video_id = match.get("video_id")
            self.usher = UsherService(match.get("domain"))

            parsed = urlparse(url)
            self.params = parse_qsd(parsed.query)
        except AttributeError:
            self.channel = None
            self.params = None
            self.video_id = None
            self.video_type = None
            self.usher = None
Exemplo n.º 6
0
    def _get_vod_streams(self):
        res = urlget(self.url)
        flashvars = re.search("FlashVars=\"(.+?)\"", res.text)

        if not flashvars:
            raise PluginError("Unable to find flashvars on page")

        flashvars = parse_qsd(flashvars.group(1))
        for var in ("vjoinid", "conid", "leagueid"):
            if not var in flashvars:
                raise PluginError(("Missing key '{0}' in flashvars").format(var))

        streams = {}
        qualities = ["SQ", "HQ"]

        for quality in qualities:
            params = dict(leagueid=flashvars["leagueid"], vjoinid=flashvars["vjoinid"],
                          conid=flashvars["conid"], title="", ref="",
                          tmpstamp=int(time.time()), strLevel=quality)
            res = urlget(self.GOXVODURL, params=params, session=self.rsession)

            if res.text != "1002" and len(res.text) > 0:
                gox = self._parse_gox_file(res.text)
                entry = gox[0]

                nokey = False
                for var in ("NODEIP", "NODEID", "UNO", "USERIP"):
                    if not var in entry:
                        nokey = True

                if nokey:
                    self.logger.warning("Unable to fetch key, make sure that you have access to this VOD")
                    continue

                key = self._check_vod_key(entry["NODEIP"], entry["NODEID"], entry["UNO"],
                                          entry["USERIP"])

                streams[quality.lower()] = HTTPStream(self.session, gox[0]["REF"],
                                                      params=dict(key=key),
                                                      headers=self.StreamHeaders)


        return streams
Exemplo n.º 7
0
    def get_vod_streams(self):
        flashvars = re.search("FlashVars=\"(.+?)\"", self.res.text)

        if not flashvars:
            raise NoStreamsError(self.url)

        flashvars = parse_qsd(flashvars.group(1))
        streams = {}

        for strlevel in self.VODQualityLevels:
            params = self._create_gox_params(flashvars, strlevel, "vod")
            res = urlget(self.GOXURL, params=params, session=self.rsession)

            gox = GOXFile(res.text)

            for entry in gox.entries:
                nokey = False

                for attr in ("nodeip", "nodeip", "uno", "userip"):
                    if not hasattr(entry, attr):
                        nokey = True

                if nokey:
                    continue

                try:
                    key = self._check_vod_key(entry.nodeip, entry.nodeid,
                                              entry.uno, entry.userip)
                except PluginError as err:
                    self.logger.warning(err)
                    continue

                streams[strlevel.lower()] = HTTPStream(self.session, entry.ref[0],
                                                       params=dict(key=key),
                                                       headers=self.StreamHeaders)

                break

        if len(streams) == 0:
            self.logger.warning(("Unable to access any streams, "
                                 "make sure you have access to this VOD"))

        return streams
Exemplo n.º 8
0
    def _create_stream_key(self, url):
        parsed = urlparse(url)
        params = parse_qsd(parsed.query)
        keys = ["uno", "nodeid"]

        for key in keys:
            if not key in params:
                raise PluginError(
                    ("Missing key '{0}' in key check params").format(key))

        userip = self._get_user_ip()
        nodeip = parsed.netloc

        try:
            conn = socket.create_connection(
                (nodeip, self.VODStreamKeyCheckPort), timeout=30)
        except socket.error as err:
            raise PluginError(
                ("Failed to connect to key check server: {0}").format(
                    str(err)))

        msg = "Login,0,{userno},{nodeid},{userip}\n".format(
            nodeid=params["nodeid"], userno=params["uno"], userip=userip)

        try:
            conn.sendall(bytes(msg, "ascii"))
            res = conn.recv(4096)
        except IOError as err:
            raise PluginError(
                ("Failed to communicate with key check server: {0}").format(
                    str(err)))

        if len(res) == 0:
            raise PluginError("Empty response from key check server")

        conn.close()

        res = str(res, "ascii").strip().split(",")

        return res[-1]
Exemplo n.º 9
0
    def _create_stream_key(self, url):
        parsed = urlparse(url)
        params = parse_qsd(parsed.query)
        keys = ["uno", "nodeid"]

        for key in keys:
            if not key in params:
                raise PluginError(("Missing key '{0}' in key check params").format(key))

        userip = self._get_user_ip()
        nodeip = parsed.netloc

        try:
            conn = socket.create_connection((nodeip, self.VODStreamKeyCheckPort),
                                            timeout=30)
        except socket.error as err:
            raise PluginError(("Failed to connect to key check server: {0}").format(str(err)))

        msg = "Login,0,{userno},{nodeid},{userip}\n".format(nodeid=params["nodeid"],
                                                            userno=params["uno"],
                                                            userip=userip)

        try:
            conn.sendall(bytes(msg, "ascii"))
            res = conn.recv(4096)
        except IOError as err:
            raise PluginError(("Failed to communicate with key check server: {0}").format(str(err)))

        if len(res) == 0:
            raise PluginError("Empty response from key check server")

        conn.close()

        res = str(res, "ascii").strip().split(",")

        return res[-1]
Exemplo n.º 10
0
    def get_vod_streams(self):
        match = re.search("flashvars\s+=\s+({.+?});", self.res.text)

        if not match:
            raise NoStreamsError(self.url)

        flashvars = parse_json(match.group(1), "flashvars JSON")

        match = re.search("var jsonData\s+= eval \((.+?)\);", self.res.text,
                          re.DOTALL)

        if not match:
            raise NoStreamsError(self.url)

        playlists = parse_json(match.group(1), "playlist JSON")

        self.logger.info("Playlist items found:")
        for i, playlist in enumerate(playlists):
            for fvars in playlist:
                if self.url[-1] != "/":
                    url = self.url + "/"
                else:
                    url = self.url

                url = urljoin(url, "?set={1}&lang={0}".format(i, fvars["set"]))

                self.logger.info("[Set {1} ({0})] {2}", self.Lang[i],
                                 fvars["set"], url)

        params = parse_qsd(urlparse(self.url).query)
        currentset = int(params.get("set", "1"))
        lang = int(params.get("lang", "0"))

        flashvars.update(playlists[lang][currentset - 1])
        flashvars["uip"] = self._get_user_ip()

        streams = {}

        for level, levelname in self.VODQualityLevels.items():
            params = self._create_gox_params(flashvars, level)

            res = urlget(self.GOXVODURL, params=params, session=self.rsession)

            gox = GOXFile(res.text)
            entries = gox.filter_entries("vod")

            for entry in entries:
                streamurl = entry.ref[0]
                params = {}

                try:
                    params["key"] = self._create_stream_key(streamurl)
                except PluginError as err:
                    self.logger.warning("{0}", str(err))
                    continue

                streams[levelname] = HTTPStream(self.session,
                                                streamurl,
                                                params=params)

        if len(streams) == 0:
            self.logger.warning(("Unable to access any streams, "
                                 "make sure you have access to this VOD"))

        return streams
Exemplo n.º 11
0
    def _get_streams(self):
        channelname = urlparse(self.url).path.rstrip("/").rpartition("/")[-1].lower()
        self.logger.debug("Fetching stream info")

        headers = {
            "Referer": self.SWFURL
        }

        form = dict(cid=channelname, watchTime="0",
                    firstConnect="1", ip="NaN")

        res = urlopen(self.APIURL, data=form, headers=headers)

        params = parse_qsd(res.text)

        if "0" in params and int(params["0"]) <= 0:
            raise PluginError("Server refused to send required parameters.")

        rtmp = params["10"]
        playpath = params["11"]
        multibitrate = int(params["20"])
        premiumuser = params["5"]
        blocktype = int(params["13"])

        if blocktype != 0:
            if blocktype == 1:
                blocktime = params["14"]
                reconnectiontime = params["16"]
                msg = ("You have crossed free viewing limit. ",
                       "You have been blocked for %s minutes. " % blocktime,
                       "Try again in %s minutes." % reconnectiontime)
                raise PluginError(msg)
            elif blocktype == 11:
                raise PluginError("No free slots available.")

        if "73" in params:
            token = params["73"]
        else:
            raise PluginError("Server seems busy, please try after some time.")

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

        streams = {}
        stream_name = "sd"

        if multibitrate:
            streams[stream_name] = RTMPStream(self.session, {
                "rtmp": "{0}/{1}".format(rtmp, playpath),
                "pageUrl": self.url,
                "swfVfy": self.SWFURL,
                "weeb": token,
                "live": True
            })
            playpath += "HI"
            stream_name = "hd"

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

        return streams
Exemplo n.º 12
0
    def get_vod_streams(self):
        match = re.search("flashvars\s+=\s+({.+?});", self.res.text)

        if not match:
            raise NoStreamsError(self.url)

        flashvars = parse_json(match.group(1), "flashvars JSON")

        match = re.search("var jsonData\s+= eval \((.+?)\);",
                             self.res.text, re.DOTALL)

        if not match:
            raise NoStreamsError(self.url)

        playlists = parse_json(match.group(1), "playlist JSON")

        self.logger.info("Playlist items found:")
        for i, playlist in enumerate(playlists):
            for fvars in playlist:
                if self.url[-1] != "/":
                    url = self.url + "/"
                else:
                    url = self.url

                url = urljoin(url, "?set={1}&lang={0}".format(i,
                              fvars["set"]))

                self.logger.info("[Set {1} ({0})] {2}", self.Lang[i],
                                                        fvars["set"],
                                                        url)

        params = parse_qsd(urlparse(self.url).query)
        currentset = int(params.get("set", "1"))
        lang = int(params.get("lang", "0"))

        flashvars.update(playlists[lang][currentset - 1])
        flashvars["uip"] = self._get_user_ip()

        streams = {}

        for level, levelname in self.VODQualityLevels.items():
            params = self._create_gox_params(flashvars, level)

            res = urlget(self.GOXVODURL, params=params,
                         session=self.rsession)

            gox = GOXFile(res.text)
            entries = gox.filter_entries("vod")

            for entry in entries:
                streamurl = entry.ref[0]
                params = {}

                try:
                    params["key"] = self._create_stream_key(streamurl)
                except PluginError as err:
                    self.logger.warning("{0}", str(err))
                    continue

                streams[levelname] = HTTPStream(self.session, streamurl,
                                                params=params)

        if len(streams) == 0:
            self.logger.warning(("Unable to access any streams, "
                                 "make sure you have access to this VOD"))

        return streams
Exemplo n.º 13
0
    def _get_streams(self):
        channelname = urlparse(
            self.url).path.rstrip("/").rpartition("/")[-1].lower()
        self.logger.debug("Fetching stream info")

        headers = {"Referer": self.SWFURL}

        form = dict(cid=channelname, watchTime="0", firstConnect="1", ip="NaN")

        res = http.post(self.APIURL, data=form, headers=headers)

        params = parse_qsd(res.text)

        if "0" in params and int(params["0"]) <= 0:
            raise PluginError("Server refused to send required parameters.")

        rtmp = params["10"]
        playpath = params["11"]
        multibitrate = int(params["20"])
        premiumuser = params["5"]
        blocktype = int(params["13"])

        if blocktype != 0:
            if blocktype == 1:
                blocktime = params["14"]
                reconnectiontime = params["16"]
                msg = ("You have crossed free viewing limit. ",
                       "You have been blocked for %s minutes. " % blocktime,
                       "Try again in %s minutes." % reconnectiontime)
                raise PluginError(msg)
            elif blocktype == 11:
                raise PluginError("No free slots available.")

        if "73" in params:
            token = params["73"]
        else:
            raise PluginError("Server seems busy, please try after some time.")

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

        streams = {}
        stream_name = "sd"

        if multibitrate:
            streams[stream_name] = RTMPStream(
                self.session, {
                    "rtmp": "{0}/{1}".format(rtmp, playpath),
                    "pageUrl": self.url,
                    "swfVfy": self.SWFURL,
                    "weeb": token,
                    "live": True
                })
            playpath += "HI"
            stream_name = "hd"

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

        return streams
Exemplo n.º 14
0
    def _get_streams(self):
        self.logger.debug("Fetching stream info")

        headers = {"Referer": self.url}

        res = urlget(self.url, headers=headers)
        match = re.search("flashvars.*?cid[^\d]+?(\d+)", res.text)
        if not match:
            raise NoStreamsError(self.url)

        headers = {"Referer": self.SWFURL}

        form = dict(cid=match.group(1),
                    watchTime="0",
                    firstConnect="1",
                    ip="NaN")

        res = urlopen(self.APIURL, data=form, headers=headers)

        params = parse_qsd(res.text)

        if "0" in params and int(params["0"]) <= 0:
            raise StreamError("Server refused to send required parameters.")

        rtmp = params["10"]
        playpath = params["11"]
        multibitrate = int(params["20"])
        premiumuser = params["5"]
        blocktype = int(params["13"])

        if blocktype != 0:
            if blocktype == 1:
                blocktime = params["14"]
                reconnectiontime = params["16"]
                msg = ("You have crossed free viewing limit. ",
                       "You have been blocked for %s minutes. " % blocktime,
                       "Try again in %s minutes." % reconnectiontime)
                raise StreamError(msg)
            elif blocktype == 11:
                raise StreamError("No free slots available.")

        if "73" in params:
            token = params["73"]
        else:
            raise StreamError("Server seems busy, please try after some time.")

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

        streams = {}

        if multibitrate:
            streams["low"] = RTMPStream(
                self.session, {
                    "rtmp": "{0}/{1}".format(rtmp, playpath),
                    "pageUrl": self.url,
                    "swfVfy": self.SWFURL,
                    "weeb": token,
                    "live": True
                })
            playpath += "HI"

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

        return streams