Exemplo n.º 1
0
def parse_stream_map(streammap):
    streams = []
    if not streammap:
        return streams

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

    return streams
Exemplo n.º 2
0
def parse_stream_map(streammap):
    streams = []
    if not streammap:
        return streams

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

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

        match = _url_re.match(url).groupdict()
        self.channel = match.get("channel").lower()
        self.subdomain = match.get("subdomain")
        self.video_type = match.get("video_type")
        self.video_id = match.get("video_id")

        parsed = urlparse(url)
        self.params = parse_query(parsed.query)

        self.api = TwitchAPI(beta=self.subdomain == "beta")
        self.usher = UsherService()
Exemplo n.º 6
0
    def __init__(self, url):
        Plugin.__init__(self, url)

        match = _url_re.match(url).groupdict()
        self.channel = match.get("channel").lower()
        self.subdomain = match.get("subdomain")
        self.video_type = match.get("video_type")
        self.video_id = match.get("video_id")

        parsed = urlparse(url)
        self.params = parse_query(parsed.query)

        self.api = TwitchAPI(beta=self.subdomain == "beta")
        self.usher = UsherService()
Exemplo n.º 7
0
    def _get_stream_info(self, url):
        match = _url_re.match(url)
        user = match.group("user")

        if user:
            video_id = self._find_channel_video()
        else:
            video_id = match.group("video_id")

        if not video_id:
            return

        params = {"video_id": video_id, "el": "player_embedded"}
        res = http.get(API_VIDEO_INFO, params=params)

        return parse_query(res.text, name="config", schema=_config_schema)
Exemplo n.º 8
0
    def _get_stream_info(self, url):
        match = _url_re.match(url)
        user = match.group("user")

        if user:
            video_id = self._find_channel_video()
        else:
            video_id = match.group("video_id")

        if not video_id:
            return

        params = {
            "video_id": video_id,
            "el": "player_embedded"
        }
        res = http.get(API_VIDEO_INFO, params=params)

        return parse_query(res.text, name="config", schema=_config_schema)
Exemplo n.º 9
0
    def __init__(self, url):
        Plugin.__init__(self, url)

        try:
            match = _url_re.match(url).groupdict()
            self.channel = match.get("channel").lower()
            self.subdomain = match.get("subdomain")
            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_query(parsed.query)
        except AttributeError:
            self.channel = None
            self.params = None
            self.subdomain = None
            self.video_id = None
            self.video_type = None
            self.usher = None
Exemplo n.º 10
0
def parse_stream_map(stream_map):
    if not stream_map:
        return []

    return [parse_query(s) for s in stream_map.split(",")]
Exemplo n.º 11
0
def parse_stream_map(stream_map):
    if not stream_map:
        return []

    return [parse_query(s) for s in stream_map.split(",")]