Compare commits
2 Commits
d75533cb25
...
451969150e
| Author | SHA1 | Date | |
|---|---|---|---|
| 451969150e | |||
| e950d53fe1 |
@@ -416,7 +416,7 @@ class JOYNAT(Service):
|
|||||||
self, *, challenge: bytes, title: Union[Movies, Series], track: AnyTrack,
|
self, *, challenge: bytes, title: Union[Movies, Series], track: AnyTrack,
|
||||||
) -> Optional[Union[bytes, str]]:
|
) -> Optional[Union[bytes, str]]:
|
||||||
"""Obtain a Widevine license for the given track."""
|
"""Obtain a Widevine license for the given track."""
|
||||||
license_url = getattr(track, 'data', {}).get('license_url') if track.data else None
|
license_url = track.data.get('license_url')
|
||||||
if not license_url:
|
if not license_url:
|
||||||
raise ValueError("No license_url in track.data.")
|
raise ValueError("No license_url in track.data.")
|
||||||
|
|
||||||
@@ -441,7 +441,7 @@ class JOYNAT(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()
|
||||||
@@ -451,6 +451,9 @@ class JOYNAT(Service):
|
|||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
|
|
||||||
|
if response_data.get("errors"):
|
||||||
|
raise ValueError(f"GraphQL errors for '{operation_name}': {response_data['errors']}")
|
||||||
|
|
||||||
if 'data' not in response_data:
|
if 'data' not in response_data:
|
||||||
self.log.error(f"GraphQL response for '{operation_name}' missing 'data' field.")
|
self.log.error(f"GraphQL response for '{operation_name}' missing 'data' field.")
|
||||||
raise ValueError(f"Invalid GraphQL response for '{operation_name}'.")
|
raise ValueError(f"Invalid GraphQL response for '{operation_name}'.")
|
||||||
|
|||||||
@@ -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(),
|
||||||
@@ -436,8 +437,13 @@ class RTLP(Service):
|
|||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
|
|
||||||
|
if response_data.get("errors"):
|
||||||
|
raise ValueError(f"GraphQL errors for '{operation_name}': {response_data['errors']}")
|
||||||
|
|
||||||
if 'data' not in response_data:
|
if 'data' not in response_data:
|
||||||
raise ValueError(f"Invalid GraphQL response for '{operation_name}': missing 'data' field.")
|
self.log.error(f"GraphQL response for '{operation_name}' missing 'data' field.")
|
||||||
|
raise ValueError(f"Invalid GraphQL response for '{operation_name}'.")
|
||||||
|
|
||||||
return response_data['data']
|
return response_data['data']
|
||||||
|
|
||||||
|
|||||||
@@ -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