This commit is contained in:
√(noham)²
2026-02-14 14:39:41 +01:00
parent 754632a47a
commit 8609f6a6a2

View File

@@ -214,46 +214,56 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
).json() ).json()
return data["result"]["token"] return data["result"]["token"]
def login_cred_free(self, username, password): def login_cred_free(self, username, password):
"""Authenticate with OQEE service using Free account credentials.""" """Authenticate with OQEE service using Free account credentials."""
headers = { headers = {
'accept': '*/*', "accept": "*/*",
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8', "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
'cache-control': 'no-cache', "cache-control": "no-cache",
'content-type': 'application/json', "content-type": "application/json",
'origin': 'https://tv.free.fr', "origin": "https://tv.free.fr",
'pragma': 'no-cache', "pragma": "no-cache",
'priority': 'u=1, i', "priority": "u=1, i",
'referer': 'https://tv.free.fr/', "referer": "https://tv.free.fr/",
'sec-ch-ua': '"Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146"', "sec-ch-ua": '"Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146"',
'sec-ch-ua-mobile': '?0', "sec-ch-ua-mobile": "?0",
'sec-ch-ua-platform': '"macOS"', "sec-ch-ua-platform": '"macOS"',
'sec-fetch-dest': 'empty', "sec-fetch-dest": "empty",
'sec-fetch-mode': 'cors', "sec-fetch-mode": "cors",
'sec-fetch-site': 'cross-site', "sec-fetch-site": "cross-site",
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36', "user-agent": (
'x-oqee-customization': '0', "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
'x-oqee-platform': 'web', "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
),
"x-oqee-customization": "0",
"x-oqee-platform": "web",
} }
data = {"provider":"oqee","platform":"web"} data = {"provider": "oqee", "platform": "web"}
response = self.session.post('https://api.oqee.net/api/v2/user/oauth/init', headers=headers, json=data).json() response = self.session.post(
redirect_url = response['result']['redirect_url'] "https://api.oqee.net/api/v2/user/oauth/init", headers=headers, json=data
token = parse_qs(urlparse(redirect_url).query)['token'][0] ).json()
redirect_url = response["result"]["redirect_url"]
token = parse_qs(urlparse(redirect_url).query)["token"][0]
data = {"email":username,"password":password,"token":token} data = {"email": username, "password": password, "token": token}
response = self.session.post('https://api.oqee.net/api/v1/user/oauthorize', headers=headers, json=data).json() response = self.session.post(
"https://api.oqee.net/api/v1/user/oauthorize",
headers=headers,
json=data,
).json()
if not response["success"]: if not response["success"]:
error_msg = response.get("error", {}).get("msg", "No error message")
raise ValueError( raise ValueError(
f"Login failed: invalid credentials or error in authentication - {response.get('error', {}).get('msg', 'No error message')}" f"Login failed: invalid credentials or error in authentication - {error_msg}"
) )
parsed_url = parse_qs(urlparse(response["result"]["redirect_url"]).query) parsed_url = parse_qs(urlparse(response["result"]["redirect_url"]).query)
if "code" not in parsed_url: if "code" not in parsed_url:
raise ValueError( raise ValueError(
"Login failed: invalid credentials or error in authentication - no code in redirect URL" "Login failed: invalid credentials or error in authentication "
"- no code in redirect URL"
) )
code = parsed_url["code"][0] code = parsed_url["code"][0]
@@ -264,7 +274,6 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
).json() ).json()
return data["result"]["token"] return data["result"]["token"]
def login_ip(self): def login_ip(self):
""" """
Performs IP-based authentication with the OQEE service. Performs IP-based authentication with the OQEE service.
@@ -288,10 +297,14 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
else: else:
try: try:
if self.abo: if self.abo:
logger.info("Logging in with provided credentials (abo account detected).") logger.info(
"Logging in with provided credentials (abo account detected)."
)
self.access_token = self.login_cred_abo(username, password) self.access_token = self.login_cred_abo(username, password)
else: else:
logger.info("Logging in with provided credentials (free account detected).") logger.info(
"Logging in with provided credentials (free account detected)."
)
self.access_token = self.login_cred_free(username, password) self.access_token = self.login_cred_free(username, password)
except ValueError as e: except ValueError as e:
logger.warning( logger.warning(
@@ -301,7 +314,10 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
logger.info("Fetching rights token") logger.info("Fetching rights token")
self.right_token = self.right() self.right_token = self.right()
logger.debug("Rights token obtained: %s", self.right_token[:10] + "..." if self.right_token else "None") logger.debug(
"Rights token obtained: %s",
self.right_token[:10] + "..." if self.right_token else "None",
)
logger.info("Fetching profile ID") logger.info("Fetching profile ID")
self.profil_id = self.profil() self.profil_id = self.profil()
logger.debug("Profile ID obtained: %s", self.profil_id) logger.debug("Profile ID obtained: %s", self.profil_id)