def _get_streams(self): channel = self._url_re.match(self.url).group("channel") pdata = self.session.http.get(self.caronte_url.format(channel=channel), acceptable_status=(200, 403, 404), schema=self.caronte_schema) gbx = self.session.http.get(self.gbx_url.format(channel=channel), schema=self.gbx_schema) if "code" in pdata: log.error("error getting pdata: {}".format(pdata["code"])) return tokens = self.session.http.post(pdata["cerbero"], acceptable_status=(200, 403, 404), json={"bbx": pdata["bbx"], "gbx": gbx}, headers={"origin": "https://www.mitele.es"}, schema=self.cerbero_schema) if "code" in tokens: log.error("Could not get stream tokens: {} ({})".format(tokens["code"], self.token_errors.get(tokens["code"], "unknown error"))) return for stream in pdata["dls"]: if stream["drm"]: log.warning("Stream may be protected by DRM") else: sformat = stream.get("format") log.debug("Stream: {} ({})".format(stream["stream"], sformat or "n/a")) cdn_token = tokens.get(stream["lid"], {}).get("cdn", "") qsd = parse_qsd(cdn_token) if sformat == "hls": yield from HLSStream.parse_variant_playlist(self.session, update_qsd(stream["stream"], qsd)).items()
def test_parse_qsd(self): self.assertEqual({ "test": "1", "foo": "bar" }, parse_qsd("test=1&foo=bar", schema=validate.Schema({ "test": validate.text, "foo": "bar" })))
def _get_streams(self): # Get the query string encrypted_data = urlparse(self.url).query data = base64.b64decode(encrypted_data) # and decrypt it passphrase = self.passphrase() if passphrase: params = decrypt_openssl(data, passphrase) config = parse_qsd(params.decode("utf8")) return HLSStream.parse_variant_playlist(self.session, self.stream_url.format(time=self.time, deviceId=self.device_id, token=self.get_token(**config), **config))
def _get_streams(self): # Get the query string encrypted_data = urlparse(self.url).query data = base64.b64decode(encrypted_data) # and decrypt it passphrase = self.passphrase() if passphrase: self.logger.debug("Found passphrase") params = decrypt_openssl(data, passphrase) config = parse_qsd(params.decode("utf8")) hls_url = self.stream_url.format(time=self.time, deviceId=self.device_id, token=self.get_token(**config), **config) self.logger.debug("URL={0}".format(hls_url)) return HLSStream.parse_variant_playlist(self.session, hls_url, headers=self._headers)
def _get_streams(self): p = urlparse(self.url) if "ott.streann.com" != p.netloc: self._domain = p.netloc res = self.session.http.get(self.url) for iframe in itertags(res.text, "iframe"): iframe_url = html_unescape(iframe.attributes.get("src")) if "ott.streann.com" in iframe_url: self.url = iframe_url break else: log.error("Could not find 'ott.streann.com' iframe") return if not self._domain and self.get_option("url"): self._domain = urlparse(self.get_option("url")).netloc if self._domain is None: log.error("Missing source URL use --streann-url") return self.session.http.headers.update({"Referer": self.url}) # Get the query string encrypted_data = urlparse(self.url).query data = base64.b64decode(encrypted_data) # and decrypt it passphrase = self.passphrase() if passphrase: log.debug("Found passphrase") params = decrypt_openssl(data, passphrase) config = parse_qsd(params.decode("utf8")) log.trace(f"config: {config!r}") token = self.get_token(**config) if not token: return hls_url = self.stream_url.format(time=self.time, deviceId=self.device_id, token=token, **config) log.debug("URL={0}".format(hls_url)) return HLSStream.parse_variant_playlist( self.session, hls_url, acceptable_status=(200, 403, 404, 500))
def test_parse_qsd(self): self.assertEqual( {"test": "1", "foo": "bar"}, parse_qsd("test=1&foo=bar", schema=validate.Schema({"test": validate.text, "foo": "bar"})))