예제 #1
0
    def _get_live_streams(self):
        self._authenticate()
        sig, token = self._access_token()
        url = self.usher.select(self.channel,
                                password=self.options.get("password"),
                                nauthsig=sig,
                                nauth=token)

        try:
            streams = HLSStream.parse_variant_playlist(self.session, url)
        except IOError as err:
            err = str(err)
            if "404 Client Error" in err or "Failed to parse playlist" in err:
                return
            else:
                raise PluginError(err)

        try:
            token = parse_json(token, schema=_token_schema)
            for name in token["restricted_bitrates"]:
                if name not in streams:
                    self.logger.warning("The quality '{0}' is not available "
                                        "since it requires a subscription.",
                                        name)
        except PluginError:
            pass

        return dict(starmap(self._check_stream_name, streams.items()))
예제 #2
0
 def _get_stream_info(self):
     res = http.get(self.url)
     match = re.search("window.config = ({.+})", res.text)
     if match:
         config = match.group(1)
         return parse_json(config, "config JSON",
                           schema=_stream_config_schema)
예제 #3
0
    def _get_hls_streams(self, type="live"):
        self._authenticate()
        sig, token = self._access_token(type)
        if type == "live":
            url = self.usher.channel(self.channel, sig=sig, token=token)
        elif type == "video":
            url = self.usher.video(self.video_id, nauthsig=sig, nauth=token)

        try:
            streams = HLSStream.parse_variant_playlist(self.session, url)
        except IOError as err:
            err = str(err)
            if "404 Client Error" in err or "Failed to parse playlist" in err:
                return
            else:
                raise PluginError(err)

        try:
            token = parse_json(token, schema=_token_schema)
            for name in token["restricted_bitrates"]:
                if name not in streams:
                    self.logger.warning(
                        "The quality '{0}' is not available "
                        "since it requires a subscription.", name)
        except PluginError:
            pass

        return streams
예제 #4
0
    def _get_hls_streams(self, type="live"):
        self._authenticate()
        sig, token = self._access_token(type)
        if type == "live":
            url = self.usher.select(self.channel, nauthsig=sig, nauth=token)
        elif type == "video":
            url = self.usher.vod(self.video_id, nauthsig=sig, nauth=token)

        try:
            streams = HLSStream.parse_variant_playlist(self.session, url)
        except IOError as err:
            err = str(err)
            if "404 Client Error" in err or "Failed to parse playlist" in err:
                return
            else:
                raise PluginError(err)

        try:
            token = parse_json(token, schema=_token_schema)
            for name in token["restricted_bitrates"]:
                if name not in streams:
                    self.logger.warning("The quality '{0}' is not available "
                                        "since it requires a subscription.",
                                        name)
        except PluginError:
            pass

        return streams
예제 #5
0
 def _get_stream_info(self):
     res = http.get(self.url)
     match = re.search("window.config = ({.+})", res.text)
     if match:
         config = match.group(1)
         return parse_json(config, "config JSON",
                           schema=_stream_config_schema)
예제 #6
0
    def _get_streams(self):
        res = http.get(self.url)
        match = (_stream_hls_re.search(res.text) or
                 _stream_data_re.search(res.text))
        if not match:
            return

        stream_url = parse_json(match.group(1))

        return HLSStream.parse_variant_playlist(self.session, stream_url)
예제 #7
0
    def _get_streams(self):
        res = http.get(self.url)
        match = (_stream_hls_re.search(res.text)
                 or _stream_data_re.search(res.text))
        if not match:
            return

        stream_url = parse_json(match.group(1))

        return HLSStream.parse_variant_playlist(self.session, stream_url)
예제 #8
0
    def _find_store(self, res, name):
        match = _store_data_re.search(res.text)
        if not match:
            return

        stores_data = parse_json(match.group(1).replace('\\"', '"'),
                                 schema=_store_schema)
        if not stores_data:
            return

        for store in filter(lambda s: s["instanceName"] == name, stores_data):
            return store
예제 #9
0
파일: viagame.py 프로젝트: uguer30/Project
    def _find_store(self, res, name):
        match = _store_data_re.search(res.text)
        if not match:
            return

        stores_data = parse_json(match.group(1).replace('\\"', '"'),
                                 schema=_store_schema)
        if not stores_data:
            return

        for store in filter(lambda s: s["instanceName"] == name, stores_data):
            return store
예제 #10
0
    def _get_live_stream(self, export_url):
        res = http.get(export_url)
        match = _live_json_re.search(res.text)
        if not match:
            return

        json = parse_json(match.group(1), schema=_live_schema)
        streams = {}
        for stream in json["streams"]:
            stream_name = stream["quality"]
            parsed = urlparse(stream["url"])

            stream = RTMPStream(self.session, {
                "rtmp": stream["url"],
                "app": "{0}?{1}".format(parsed.path[1:], parsed.query),
                "playpath": stream["name"],
                "swfVfy": SWF_LIVE_URL,
                "pageUrl": self.url,
                "live": True
            })
            streams[stream_name] = stream

        return streams
예제 #11
0
파일: nos.py 프로젝트: uguer30/Project
    def _resolve_stream(self):
        res = http.get(self.url)
        match = _data_stream_re.search(res.text)
        if not match:
            return
        data_stream = match.group(1)

        resolve_data = {
            'stream': data_stream
        }
        res = http.post(
            'http://www-ipv4.nos.nl/livestream/resolve/',
            data=json.dumps(resolve_data)
        )
        data = http.json(res)

        res = http.get(data['url'])
        match = _js_re.search(res.text)
        if not match:
            return

        stream_url = parse_json(match.group(1))

        return HLSStream.parse_variant_playlist(self.session, stream_url)
예제 #12
0
    def _get_live_stream(self, export_url):
        res = http.get(export_url)
        match = _live_json_re.search(res.text)
        if not match:
            return

        json = parse_json(match.group(1), schema=_live_schema)
        streams = {}
        for stream in json["streams"]:
            stream_name = stream["quality"]
            parsed = urlparse(stream["url"])

            stream = RTMPStream(
                self.session, {
                    "rtmp": stream["url"],
                    "app": "{0}?{1}".format(parsed.path[1:], parsed.query),
                    "playpath": stream["name"],
                    "swfVfy": SWF_LIVE_URL,
                    "pageUrl": self.url,
                    "live": True
                })
            streams[stream_name] = stream

        return streams
예제 #13
0
파일: mlgtv.py 프로젝트: uguer30/Project
 def _find_stream_id(self, text):
     match = _player_config_re.search(text)
     if match:
         stream_id = parse_json(match.group(1),
                                schema=_player_config_schema)
         return stream_id