From 91d3f7d87c56a2cb4cb6898b57c480d1b4df94e9 Mon Sep 17 00:00:00 2001 From: Spoked Date: Tue, 5 Nov 2024 14:26:29 -0500 Subject: [PATCH] fix: wrong headers attr and added orionoid sub check --- src/program/apis/overseerr_api.py | 2 +- src/program/apis/trakt_api.py | 2 +- src/program/services/downloaders/torbox.py | 8 ++++---- src/program/services/scrapers/mediafusion.py | 2 +- src/program/services/scrapers/orionoid.py | 3 +++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/program/apis/overseerr_api.py b/src/program/apis/overseerr_api.py index 14fa497c..d8f25310 100644 --- a/src/program/apis/overseerr_api.py +++ b/src/program/apis/overseerr_api.py @@ -125,7 +125,7 @@ def delete_request(self, mediaId: int) -> bool: settings = settings_manager.settings.content.overseerr headers = {"X-Api-Key": settings.api_key} try: - response = self.request_handler.execute(HttpMethod.DELETE, f"api/v1/request/{mediaId}", additional_headers=headers) + response = self.request_handler.execute(HttpMethod.DELETE, f"api/v1/request/{mediaId}", headers=headers) logger.debug(f"Deleted request {mediaId} from overseerr") return response.is_ok == True except Exception as e: diff --git a/src/program/apis/trakt_api.py b/src/program/apis/trakt_api.py index 3a911ce8..f124df2a 100644 --- a/src/program/apis/trakt_api.py +++ b/src/program/apis/trakt_api.py @@ -223,7 +223,7 @@ def get_imdbid_from_tvdb(self, tvdb_id: str, type: str = "show") -> Optional[str def resolve_short_url(self, short_url) -> Union[str, None]: """Resolve short URL to full URL""" try: - response = self.request_handler.execute(HttpMethod.GET, endpoint=short_url, additional_headers={"Content-Type": "application/json", "Accept": "text/html"}) + response = self.request_handler.execute(HttpMethod.GET, endpoint=short_url, headers={"Content-Type": "application/json", "Accept": "text/html"}) if response.is_ok: return response.response.url else: diff --git a/src/program/services/downloaders/torbox.py b/src/program/services/downloaders/torbox.py index e9723156..54bd9a5f 100644 --- a/src/program/services/downloaders/torbox.py +++ b/src/program/services/downloaders/torbox.py @@ -42,7 +42,7 @@ # if not self.settings.api_key: # logger.error("Torbox API key is not set") # try: -# response = get(f"{self.base_url}/user/me", additional_headers=self.headers) +# response = get(f"{self.base_url}/user/me", headers=self.headers) # if response.is_ok: # user_info = response.data.data # expiration = user_info.premium_expires_at @@ -311,7 +311,7 @@ # hash_string = ",".join(hash_list) # response = get( # f"{self.base_url}/torrents/checkcached?hash={hash_string}&list_files=True", -# additional_headers=self.headers, +# headers=self.headers, # response_type=dict, # ) # return response.data["data"] @@ -321,14 +321,14 @@ # response = post( # f"{self.base_url}/torrents/createtorrent", # data={"magnet": magnet_url, "seed": 1, "allow_zip": False}, -# additional_headers=self.headers, +# headers=self.headers, # ) # return response.data.data.torrent_id # def get_torrent_list(self) -> list: # response = get( # f"{self.base_url}/torrents/mylist?bypass_cache=true", -# additional_headers=self.headers, +# headers=self.headers, # response_type=dict, # ) # return response.data["data"] diff --git a/src/program/services/scrapers/mediafusion.py b/src/program/services/scrapers/mediafusion.py index 5a184210..52782bc3 100644 --- a/src/program/services/scrapers/mediafusion.py +++ b/src/program/services/scrapers/mediafusion.py @@ -79,7 +79,7 @@ def validate(self) -> bool: headers = {"Content-Type": "application/json"} try: - response = self.request_handler.execute(HttpMethod.POST, url, overriden_response_type=ResponseType.DICT, json=payload, additional_headers=headers) + response = self.request_handler.execute(HttpMethod.POST, url, overriden_response_type=ResponseType.DICT, json=payload, headers=headers) self.encrypted_string = json.loads(response.data)["encrypted_str"] except Exception as e: logger.error(f"Failed to encrypt user data: {e}") diff --git a/src/program/services/scrapers/orionoid.py b/src/program/services/scrapers/orionoid.py index f0c8c82b..c16f1308 100644 --- a/src/program/services/scrapers/orionoid.py +++ b/src/program/services/scrapers/orionoid.py @@ -46,6 +46,9 @@ def validate(self) -> bool: url = f"{self.base_url}?keyapp={KEY_APP}&keyuser={self.settings.api_key}&mode=user&action=retrieve" response = self.request_handler.execute(HttpMethod.GET, url, timeout=self.timeout) if response.is_ok and hasattr(response.data, "result"): + if not response.data.data.subscription.package.enabled: + logger.error("Orionoid subscription is not active. Please check your subscription status.") + return False if response.data.result.status != "success": logger.error( f"Orionoid API Key is invalid. Status: {response.data.result.status}",