fix(RTLP): move client secret to config, use RuntimeError, and fix GraphQL variables encoding
This commit is contained in:
@@ -105,7 +105,7 @@ class RTLP(Service):
|
|||||||
|
|
||||||
auth_code_match = re.search(self.AUTH_CODE_REGEX, redirect_url)
|
auth_code_match = re.search(self.AUTH_CODE_REGEX, redirect_url)
|
||||||
if not auth_code_match:
|
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)
|
auth_code = auth_code_match.group(1)
|
||||||
self.log.debug(f"Auth Code: {auth_code}")
|
self.log.debug(f"Auth Code: {auth_code}")
|
||||||
@@ -127,13 +127,14 @@ class RTLP(Service):
|
|||||||
|
|
||||||
auth_response = response.json()
|
auth_response = response.json()
|
||||||
if 'access_token' not in auth_response:
|
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._rtlp_auth_jwt = auth_response['access_token']
|
||||||
self.log.info("Successfully authenticated with cookies.")
|
self.log.info("Successfully authenticated with cookies.")
|
||||||
|
|
||||||
def _authenticate_anonymous(self) -> None:
|
def _authenticate_anonymous(self) -> None:
|
||||||
token_url = self.config["endpoints"]["token_url"]
|
token_url = self.config["endpoints"]["token_url"]
|
||||||
|
client_secret = self.config["client"]["secret"]
|
||||||
|
|
||||||
response = self.session.post(
|
response = self.session.post(
|
||||||
token_url,
|
token_url,
|
||||||
@@ -141,8 +142,8 @@ class RTLP(Service):
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
data=bytes(
|
data=bytes(
|
||||||
'grant_type=client_credentials&client_id=anonymous-user'
|
f'grant_type=client_credentials&client_id={self.config["client"]["id"]}'
|
||||||
'&client_secret=4bfeb73f-1c4a-4e9f-a7fa-96aa1ad3d94c',
|
f'&client_secret={client_secret}',
|
||||||
'utf-8',
|
'utf-8',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -150,7 +151,7 @@ class RTLP(Service):
|
|||||||
|
|
||||||
auth_response = response.json()
|
auth_response = response.json()
|
||||||
if 'access_token' not in auth_response:
|
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._rtlp_auth_jwt = auth_response['access_token']
|
||||||
self.log.info("Authenticated anonymously with RTL+ service.")
|
self.log.info("Authenticated anonymously with RTL+ service.")
|
||||||
@@ -427,7 +428,7 @@ class RTLP(Service):
|
|||||||
},
|
},
|
||||||
params={
|
params={
|
||||||
'operationName': operation_name,
|
'operationName': operation_name,
|
||||||
'variables': json.dumps(variables).encode(),
|
'variables': json.dumps(variables),
|
||||||
'extensions': json.dumps({
|
'extensions': json.dumps({
|
||||||
'persistedQuery': {'version': 1, 'sha256Hash': persisted_query_hash},
|
'persistedQuery': {'version': 1, 'sha256Hash': persisted_query_hash},
|
||||||
}).encode(),
|
}).encode(),
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ endpoints:
|
|||||||
license: "https://rtlplus-widevine.streamingtech.de/index/rtlplus"
|
license: "https://rtlplus-widevine.streamingtech.de/index/rtlplus"
|
||||||
|
|
||||||
client:
|
client:
|
||||||
id: "2a970b6d-adf2-4cf6-833f-9d940c300d09"
|
id: "2a970b6d-adf2-4cf6-833f-9d940c300d09"
|
||||||
|
secret: "4bfeb73f-1c4a-4e9f-a7fa-96aa1ad3d94c"
|
||||||
Reference in New Issue
Block a user