mirror of
https://github.com/NohamR/OqeeRewind.git
synced 2026-04-08 02:50:01 +00:00
Lint
This commit is contained in:
@@ -214,46 +214,56 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
|
||||
).json()
|
||||
return data["result"]["token"]
|
||||
|
||||
|
||||
def login_cred_free(self, username, password):
|
||||
"""Authenticate with OQEE service using Free account credentials."""
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
|
||||
'cache-control': 'no-cache',
|
||||
'content-type': 'application/json',
|
||||
'origin': 'https://tv.free.fr',
|
||||
'pragma': 'no-cache',
|
||||
'priority': 'u=1, i',
|
||||
'referer': 'https://tv.free.fr/',
|
||||
'sec-ch-ua': '"Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"macOS"',
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'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',
|
||||
'x-oqee-customization': '0',
|
||||
'x-oqee-platform': 'web',
|
||||
"accept": "*/*",
|
||||
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/json",
|
||||
"origin": "https://tv.free.fr",
|
||||
"pragma": "no-cache",
|
||||
"priority": "u=1, i",
|
||||
"referer": "https://tv.free.fr/",
|
||||
"sec-ch-ua": '"Chromium";v="146", "Not-A.Brand";v="24", "Google Chrome";v="146"',
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-ch-ua-platform": '"macOS"',
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"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"
|
||||
),
|
||||
"x-oqee-customization": "0",
|
||||
"x-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()
|
||||
redirect_url = response['result']['redirect_url']
|
||||
token = parse_qs(urlparse(redirect_url).query)['token'][0]
|
||||
response = self.session.post(
|
||||
"https://api.oqee.net/api/v2/user/oauth/init", headers=headers, json=data
|
||||
).json()
|
||||
redirect_url = response["result"]["redirect_url"]
|
||||
token = parse_qs(urlparse(redirect_url).query)["token"][0]
|
||||
|
||||
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"]:
|
||||
error_msg = response.get("error", {}).get("msg", "No error message")
|
||||
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)
|
||||
if "code" not in parsed_url:
|
||||
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]
|
||||
|
||||
@@ -264,7 +274,6 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
|
||||
).json()
|
||||
return data["result"]["token"]
|
||||
|
||||
|
||||
def login_ip(self):
|
||||
"""
|
||||
Performs IP-based authentication with the OQEE service.
|
||||
@@ -288,10 +297,14 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
|
||||
else:
|
||||
try:
|
||||
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)
|
||||
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)
|
||||
except ValueError as e:
|
||||
logger.warning(
|
||||
@@ -301,7 +314,10 @@ class OqeeClient: # pylint: disable=too-many-instance-attributes
|
||||
|
||||
logger.info("Fetching rights token")
|
||||
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")
|
||||
self.profil_id = self.profil()
|
||||
logger.debug("Profile ID obtained: %s", self.profil_id)
|
||||
|
||||
Reference in New Issue
Block a user