Пример #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
    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
    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
 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