From e950d53fe133f91fbd3e0cca298172c36a44c7b3 Mon Sep 17 00:00:00 2001 From: blackicedbear Date: Mon, 2 Mar 2026 01:14:44 +0100 Subject: [PATCH] fix(RTLP): move client secret to config, use RuntimeError, and fix GraphQL variables encoding --- RTLP/__init__.py | 13 +++++++------ RTLP/config.yaml | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/RTLP/__init__.py b/RTLP/__init__.py index 866f9e0..1d1e0b0 100644 --- a/RTLP/__init__.py +++ b/RTLP/__init__.py @@ -105,7 +105,7 @@ class RTLP(Service): auth_code_match = re.search(self.AUTH_CODE_REGEX, redirect_url) if not auth_code_match: - raise EnvironmentError("Authorization code not found in redirect URL.") + raise RuntimeError("Authorization code not found in redirect URL.") auth_code = auth_code_match.group(1) self.log.debug(f"Auth Code: {auth_code}") @@ -127,13 +127,14 @@ class RTLP(Service): auth_response = response.json() if 'access_token' not in auth_response: - raise EnvironmentError("Cookie authentication failed: no access token in response.") + raise RuntimeError("Cookie authentication failed: no access token in response.") self._rtlp_auth_jwt = auth_response['access_token'] self.log.info("Successfully authenticated with cookies.") def _authenticate_anonymous(self) -> None: token_url = self.config["endpoints"]["token_url"] + client_secret = self.config["client"]["secret"] response = self.session.post( token_url, @@ -141,8 +142,8 @@ class RTLP(Service): 'Content-Type': 'application/x-www-form-urlencoded', }, data=bytes( - 'grant_type=client_credentials&client_id=anonymous-user' - '&client_secret=4bfeb73f-1c4a-4e9f-a7fa-96aa1ad3d94c', + f'grant_type=client_credentials&client_id={self.config["client"]["id"]}' + f'&client_secret={client_secret}', 'utf-8', ), ) @@ -150,7 +151,7 @@ class RTLP(Service): auth_response = response.json() if 'access_token' not in auth_response: - raise EnvironmentError("Anonymous authentication failed: no access token in response.") + raise RuntimeError("Anonymous authentication failed: no access token in response.") self._rtlp_auth_jwt = auth_response['access_token'] self.log.info("Authenticated anonymously with RTL+ service.") @@ -427,7 +428,7 @@ class RTLP(Service): }, params={ 'operationName': operation_name, - 'variables': json.dumps(variables).encode(), + 'variables': json.dumps(variables), 'extensions': json.dumps({ 'persistedQuery': {'version': 1, 'sha256Hash': persisted_query_hash}, }).encode(), diff --git a/RTLP/config.yaml b/RTLP/config.yaml index bc0f1c3..a915411 100644 --- a/RTLP/config.yaml +++ b/RTLP/config.yaml @@ -10,4 +10,5 @@ endpoints: license: "https://rtlplus-widevine.streamingtech.de/index/rtlplus" client: - id: "2a970b6d-adf2-4cf6-833f-9d940c300d09" \ No newline at end of file + id: "2a970b6d-adf2-4cf6-833f-9d940c300d09" + secret: "4bfeb73f-1c4a-4e9f-a7fa-96aa1ad3d94c" \ No newline at end of file