From 5713bab6099326fcfe592f5b22fa042cad269fc1 Mon Sep 17 00:00:00 2001 From: Yozora Date: Thu, 9 Jan 2025 10:20:58 +0000 Subject: [PATCH 1/7] push some error codes --- modules/anidb.py | 12 ++++++------ modules/anilist.py | 16 ++++++++-------- modules/imdb.py | 28 ++++++++++++++-------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/anidb.py b/modules/anidb.py index 8446041da..eb6aef1db 100644 --- a/modules/anidb.py +++ b/modules/anidb.py @@ -55,7 +55,7 @@ def _parse(attr, xpath, is_list=False, is_dict=False, is_int=False, is_float=Fal except (ValueError, TypeError): pass if fail: - raise Failed(f"AniDB Error: No Anime Found for AniDB ID: {self.anidb_id}") + raise Failed(f"[MCE0001] AniDB Error: No Anime Found for AniDB ID: {self.anidb_id}") elif is_list: return [] elif is_dict: @@ -118,7 +118,7 @@ def authorize(self, client, version, expiration): self.version = None if self.cache: self.cache.update_testing("anidb_login", self.client, self.version, "False") - raise + raise Failed("[CFE0002] AniDB Connection Error: Client/Version could not be verified. Please check these are correct. AniDB Library Operations will not function until this is resolved.") from e @property def is_authorized(self): @@ -129,7 +129,7 @@ def login(self, username, password): logger.secret(password) data = {"show": "main", "xuser": username, "xpass": password, "xdoautologin": "on"} if not self._request(urls["login"], data=data).xpath("//li[@class='sub-menu my']/@title"): - raise Failed("AniDB Error: Login failed") + raise Failed("[CFE0003] AniDB Connection Error: Username/Password could not be verified. Please verify that the username and password are correct. AniDB Builders will still work but Mature content will not be reachable until this is resolved.") self.username = username self.password = password @@ -155,7 +155,7 @@ def _validate(self, anidb_id): ids = response.xpath(f"//*[text()='a{anidb_id}']/text()") if len(ids) > 0: return util.regex_first_int(ids[0], "AniDB ID") - raise Failed(f"AniDB Error: AniDB ID: {anidb_id} not found") + raise Failed(f"[MCE0002] AniDB Error: AniDB ID: {anidb_id} not found") def validate_anidb_ids(self, anidb_ids): anidb_list = util.get_int_list(anidb_ids, "AniDB ID") @@ -167,7 +167,7 @@ def validate_anidb_ids(self, anidb_ids): logger.error(e) if len(anidb_values) > 0: return anidb_values - raise Failed(f"AniDB Error: No valid AniDB IDs in {anidb_list}") + raise Failed(f"[BLE0001] AniDB Error: No valid AniDB IDs in {anidb_list}") def _tag(self, tag, limit): anidb_ids = [] @@ -220,7 +220,7 @@ def get_anidb_ids(self, method, data): logger.info(f"Processing AniDB Relation: {data}") anidb_ids.extend(self._relations(data)) else: - raise Failed(f"AniDB Error: Method {method} not supported") + raise Failed(f"[BLE0002] AniDB Error: Method {method} not supported") logger.debug("") logger.debug(f"{len(anidb_ids)} AniDB IDs Found") logger.trace(f"IDs: {anidb_ids}") diff --git a/modules/anilist.py b/modules/anilist.py index 933691856..ddc2b7480 100644 --- a/modules/anilist.py +++ b/modules/anilist.py @@ -88,7 +88,7 @@ def _request(self, query, variables, level=1): time.sleep(wait_time if wait_time > 0 else 10) if level < 6: return self._request(query, variables, level=level + 1) - raise Failed(f"AniList Error: Connection Failed") + raise Failed(f"[CFE0004] AniList Error: Connection Failed") else: raise Failed(f"AniList Error: {json_obj['errors'][0]['message']}") else: @@ -100,7 +100,7 @@ def _validate_id(self, anilist_id): media = self._request(query, {"id": anilist_id})["data"]["Media"] if media["id"]: return media["id"], media["title"]["english" if media["title"]["english"] else "romaji"] - raise Failed(f"AniList Error: No AniList ID found for {anilist_id}") + raise Failed(f"[BLE0003] AniList Error: No AniList ID found for {anilist_id}") def _pagenation(self, query, limit=0, variables=None): anilist_ids = [] @@ -255,13 +255,13 @@ def validate_userlist(self, data): variables = {"user": data["username"]} json_obj = self._request(query, variables) if not json_obj["data"]["MediaListCollection"]: - raise Failed(f"AniList Error: User: {data['username']} not found") + raise Failed(f"[BLE0007] AniList Error: User: {data['username']} not found") list_names = [n["name"] for n in json_obj["data"]["MediaListCollection"]["lists"]] if not list_names: - raise Failed(f"AniList Error: User: {data['username']} has no Lists") + raise Failed(f"[BLE0008] AniList Error: User: {data['username']} has no Lists") if data["list_name"] in list_names: return data - raise Failed(f"AniList Error: List: {data['list_name']} not found\nOptions: {', '.join(list_names)}") + raise Failed(f"[BLE0004] AniList Error: List: {data['list_name']} not found\nOptions: {', '.join(list_names)}") def validate(self, name, data): valid = [] @@ -270,7 +270,7 @@ def validate(self, name, data): valid.append(d) if len(valid) > 0: return valid - raise Failed(f"AniList Error: {name}: {data} does not exist\nOptions: {', '.join([v for k, v in self.options[name].items()])}") + raise Failed(f"[BLE0005] AniList Error: {name}: {data} does not exist\nOptions: {', '.join([v for k, v in self.options[name].items()])}") def validate_anilist_ids(self, anilist_ids, studio=False): anilist_id_list = util.get_int_list(anilist_ids, "AniList ID") @@ -283,7 +283,7 @@ def validate_anilist_ids(self, anilist_ids, studio=False): except Failed as e: logger.error(e) if len(anilist_values) > 0: return anilist_values - raise Failed(f"AniList Error: No valid AniList IDs in {anilist_ids}") + raise Failed(f"[BLE0006] AniList Error: No valid AniList IDs in {anilist_ids}") def get_anilist_ids(self, method, data): if method == "anilist_id": @@ -307,7 +307,7 @@ def get_anilist_ids(self, method, data): elif method == "anilist_top_rated": data = {"limit": data, "score.gt": 3, "sort_by": "score"} elif method not in builders: - raise Failed(f"AniList Error: Method {method} not supported") + raise Failed(f"[BLE0009] AniList Error: Method {method} not supported") message = f"Processing {method.replace('_', ' ').title().replace('Anilist', 'AniList')}:\n\tSort By {pretty_names[data['sort_by']]}" if data['limit'] > 0: message += f"\n\tLimit to {data['limit']} Anime" diff --git a/modules/imdb.py b/modules/imdb.py index 9dcc7a3b2..fc704c4dd 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -216,19 +216,19 @@ def validate_imdb(self, err_type, method, imdb_dicts): imdb_dict[main] = imdb_dict["url"] dict_methods = {dm.lower(): dm for dm in imdb_dict} if main not in dict_methods: - raise Failed(f"{err_type} Error: {method} {main} attribute not found") + raise Failed(f"[BLE0010] IMDb {err_type} Error: {method} {main} attribute not found") elif imdb_dict[dict_methods[main]] is None: - raise Failed(f"{err_type} Error: {method} {main} attribute is blank") + raise Failed(f"[BLE0011] IMDb {err_type} Error: {method} {main} attribute is blank") else: main_data = imdb_dict[dict_methods[main]].strip() if method == "imdb_list": if main_data.startswith(f"{base_url}/search/"): - raise Failed(f"IMDb Error: URLs with https://www.imdb.com/search/ no longer works with {method} use imdb_search.") + raise Failed(f"[BLE0012] IMDb Error: URLs with https://www.imdb.com/search/ no longer works with {method} use imdb_search.") if main_data.startswith(f"{base_url}/filmosearch/"): - raise Failed(f"IMDb Error: URLs with https://www.imdb.com/filmosearch/ no longer works with {method} use imdb_search.") + raise Failed(f"[BLE0013] IMDb Error: URLs with https://www.imdb.com/filmosearch/ no longer works with {method} use imdb_search.") search = re.search(r"(ls\d+)", main_data) if not search: - raise Failed(f"IMDb Error: {method} {main} must begin with ls (ex. ls005526372)") + raise Failed(f"[BLE0014] IMDb Error: {method} {main} must begin with ls (ex. ls005526372)") new_dict = {main: search.group(1)} else: user_id = None @@ -238,12 +238,12 @@ def validate_imdb(self, err_type, method, imdb_dicts): except ValueError: pass if not user_id: - raise Failed(f"{err_type} Error: {method} {main}: {main_data} not in the format of 'ur########'") + raise Failed(f"[BLE0015] IMDb {err_type} Error: {method} {main}: {main_data} not in the format of 'ur########'") new_dict = {main: main_data} if "limit" in dict_methods: if imdb_dict[dict_methods["limit"]] is None: - logger.warning(f"{err_type} Warning: {method} limit attribute is blank using 0 as default") + logger.warning(f"[BLW0001] IMDb {err_type} Warning: {method} limit attribute is blank using 0 as default") else: try: value = int(str(imdb_dict[dict_methods["limit"]])) @@ -252,7 +252,7 @@ def validate_imdb(self, err_type, method, imdb_dicts): except ValueError: pass if "limit" not in new_dict: - logger.warning(f"{err_type} Warning: {method} limit attribute: {imdb_dict[dict_methods['limit']]} must be an integer 0 or greater using 0 as default") + logger.warning(f"[BLW0002] IMDb {err_type} Warning: {method} limit attribute: {imdb_dict[dict_methods['limit']]} must be an integer 0 or greater using 0 as default") if "limit" not in new_dict: new_dict["limit"] = 0 @@ -447,10 +447,10 @@ def _pagination(self, data, list_type): logger.exorcise() if len(imdb_ids) > 0: return imdb_ids - raise Failed("IMDb Error: No IMDb IDs Found") + raise Failed("[BLE0016] IMDb Error: No IMDb IDs Found") except KeyError: if 'errors' in response_json.keys() and 'message' in response_json['errors'][0] and response_json['errors'][0]['message'] == 'PersistedQueryNotFound': - raise Failed("Internal IMDB PersistedQuery Error") + raise Failed("[BLE0017] IMDb Error: Internal PersistedQuery Error. Contact the Kometa Team.") logger.error(f"Response: {response_json}") raise @@ -503,7 +503,7 @@ def keywords(self, imdb_id, language, ignore_cache=False): return imdb_keywords keywords = self._request(f"{base_url}/title/{imdb_id}/keywords", language=language, xpath="//td[@class='soda sodavote']") if not keywords: - raise Failed(f"IMDb Error: No Item Found for IMDb ID: {imdb_id}") + raise Failed(f"[BLE0018] IMDb Error: No keywords found for IMDb ID: {imdb_id}") for k in keywords: name = k.xpath("div[@class='sodatext']/a/text()")[0] relevant = k.xpath("div[@class='did-you-know-actions']/div/a/text()")[0].strip() @@ -530,14 +530,14 @@ def parental_guide(self, imdb_id, ignore_cache=False): if v not in parental_dict: parental_dict[v] = None else: - raise Failed(f"IMDb Error: No Parental Guide Found for IMDb ID: {imdb_id}") + raise Failed(f"[BLE0019] IMDb Error: No Parental Guide Found for IMDb ID: {imdb_id}") if self.cache and not ignore_cache: self.cache.update_imdb_parental(expired, imdb_id, parental_dict, self.cache.expiration) return parental_dict def _ids_from_chart(self, chart, language): if chart not in chart_urls: - raise Failed(f"IMDb Error: chart: {chart} not ") + raise Failed(f"[BLE00020] IMDb Error: chart: {chart} not ") script_data = self._request(f"{base_url}/{chart_urls[chart]}", language=language, xpath="//script[@id='__NEXT_DATA__']/text()")[0] return [x.group(1) for x in re.finditer(r'"(tt\d+)"', script_data)] @@ -571,7 +571,7 @@ def get_imdb_ids(self, method, data, language): logger.info(f" {k}: {v}") return [(_i, "imdb") for _i in self._pagination(data, "search")] else: - raise Failed(f"IMDb Error: Method {method} not supported") + raise Failed(f"[BLE00021] IMDb Error: Method {method} not supported") def _interface(self, interface): gz = os.path.join(self.default_dir, f"title.{interface}.tsv.gz") From 2c806b43827268c09b9b4bec9fd4902137467a85 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 9 Jan 2025 10:22:44 +0000 Subject: [PATCH 2/7] group-errors Part: 1 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index 8b1378917..d00491fd7 100644 --- a/PART +++ b/PART @@ -1 +1 @@ - +1 From b1ae019bdf2908ca0c713ecaeaa553c0183daf02 Mon Sep 17 00:00:00 2001 From: Yozora Date: Thu, 9 Jan 2025 10:24:46 +0000 Subject: [PATCH 3/7] More error codes --- kometa.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kometa.py b/kometa.py index b67a46774..af811facc 100644 --- a/kometa.py +++ b/kometa.py @@ -5,7 +5,7 @@ from modules.logs import MyLogger if sys.version_info[0] != 3 or sys.version_info[1] < 9: - print("Python Version %s.%s.%s has been detected and is not supported. Kometa requires a minimum of Python 3.9.0." % (sys.version_info[0], sys.version_info[1], sys.version_info[2])) + print("[C0001] Python Version %s.%s.%s has been detected and is not supported. Kometa requires a minimum of Python 3.9.0." % (sys.version_info[0], sys.version_info[1], sys.version_info[2])) sys.exit(0) try: @@ -16,7 +16,7 @@ from plexapi.exceptions import NotFound from plexapi.video import Show, Season except (ModuleNotFoundError, ImportError) as ie: - print(f"Requirements Error: Requirements are not installed.\nPlease follow the documentation for instructions on installing requirements. ({ie})") + print(f"[C0002] Requirements Error: Requirements are not installed.\nPlease follow the documentation for instructions on installing requirements. ({ie})") sys.exit(0) system_versions = { @@ -188,10 +188,11 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): print(f"Argument Error: width argument invalid: {run_args['width']} must be an integer between 90 and 300. Using the default value of 100") run_args["width"] = 100 + if run_args["config"] and os.path.exists(run_args["config"]): default_dir = os.path.join(os.path.dirname(os.path.abspath(run_args["config"]))) elif run_args["config"] and not os.path.exists(run_args["config"]): - print(f"Config Error: Configuration file (config.yml) not found at {os.path.abspath(run_args['config'])}") + print(f"[CFE0001] Config Error: Configuration file (config.yml) not found at {os.path.abspath(run_args['config'])}") sys.exit(0) elif not os.path.exists(os.path.join(default_dir, "config.yml")): git_branch = git_branch or "master" @@ -207,10 +208,9 @@ def get_env(env_str, default, arg_bool=False, arg_int=False): else: raise requests.RequestException except requests.RequestException as e: - print(f"Config Error: Unable to download the configuration file from GitHub (URL: {github_url}'). Please save it as '{config_path}' before running Kometa again.") + print(f"[CFE0005] Config Error: Unable to download the configuration file from GitHub (URL: {github_url}'). Please save it as '{config_path}' before running Kometa again.") sys.exit(1) - logger = MyLogger("Kometa", default_dir, run_args["width"], run_args["divider"][0], run_args["ignore-ghost"], run_args["tests"] or run_args["debug"], run_args["trace"], run_args["log-requests"]) @@ -306,7 +306,7 @@ def start(attrs): if sys_ver and sys_ver != required_versions[req_name]: logger.info(f" {req_name} version: {sys_ver} requires an update to: {required_versions[req_name]}") except FileNotFoundError: - logger.error(" File Error: requirements.txt not found") + logger.error("[E0001] File Error: requirements.txt not found") if "time" in attrs and attrs["time"]: start_type = f"{attrs['time']} " elif run_args["tests"]: start_type = "Test " elif "collections" in attrs and attrs["collections"]: start_type = "Collections " @@ -363,7 +363,7 @@ def start(attrs): config.Webhooks.end_time_hooks(start_time, end_time, run_time, stats) except Failed as e: logger.stacktrace() - logger.error(f"Webhooks Error: {e}") + logger.error(f"[E0002] Webhooks Error: {e}") version_line = f"Version: {my_requests.local}" if my_requests.newest: version_line = f"{version_line} Newest Version: {my_requests.newest}" @@ -659,7 +659,7 @@ def run_libraries(config): library.delete(collection) logger.info(f"Collection {collection.title} Deleted") except Failed as e: - logger.error(e) + logger.error(f"[E0003] {collection.title} | Collection could not be removed") library_status[library.name]["All Collections Deleted"] = str(datetime.now() - time_start).split('.')[0] if run_args["delete-labels"] and not run_args["playlists-only"]: @@ -679,7 +679,7 @@ def run_libraries(config): sync = ["Overlay"] if "Overlay" in [lbl.tag for lbl in item.labels] else [] library.edit_tags("label", item, sync_tags=sync) except NotFound: - logger.error(f"{item.title[:25]:<25} | Labels Failed to be Removed") + logger.error(f"[E0004] {item.title[:25]:<25} | Labels Failed to be Removed") library_status[library.name]["All Labels Deleted"] = str(datetime.now() - time_start).split('.')[0] time_start = datetime.now() @@ -1180,7 +1180,7 @@ def run_playlists(config): time_str += f"{minutes} Minute{'s' if minutes > 1 else ''}" logger.ghost(f"Current Time: {current_time} | {time_str} until the next run at {og_time_str} | Runs: {', '.join(valid_times)}") else: - logger.error(f"Time Error: {valid_times}") + logger.error(f"[E0005] Time Error: {valid_times}") time.sleep(60) except KeyboardInterrupt: logger.separator("Exiting Kometa") From 0e00e46c93ca0c06c8bda92e9e115ec5a480dfe9 Mon Sep 17 00:00:00 2001 From: Yozora Date: Thu, 9 Jan 2025 15:02:31 +0000 Subject: [PATCH 4/7] push more error codes --- modules/anidb.py | 4 ++-- modules/github.py | 2 +- modules/icheckmovies.py | 6 +++--- modules/letterboxd.py | 8 ++++---- modules/mal.py | 18 +++++++++--------- modules/mdblist.py | 30 +++++++++++++++--------------- modules/mojo.py | 4 ++-- modules/notifiarr.py | 4 ++-- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/modules/anidb.py b/modules/anidb.py index eb6aef1db..599951f36 100644 --- a/modules/anidb.py +++ b/modules/anidb.py @@ -118,7 +118,7 @@ def authorize(self, client, version, expiration): self.version = None if self.cache: self.cache.update_testing("anidb_login", self.client, self.version, "False") - raise Failed("[CFE0002] AniDB Connection Error: Client/Version could not be verified. Please check these are correct. AniDB Library Operations will not function until this is resolved.") from e + raise Failed("[CFE0002] Connector Error: AniDB Client/Version could not be verified. Please check these are correct. AniDB Library Operations will not function until this is resolved.") from e @property def is_authorized(self): @@ -129,7 +129,7 @@ def login(self, username, password): logger.secret(password) data = {"show": "main", "xuser": username, "xpass": password, "xdoautologin": "on"} if not self._request(urls["login"], data=data).xpath("//li[@class='sub-menu my']/@title"): - raise Failed("[CFE0003] AniDB Connection Error: Username/Password could not be verified. Please verify that the username and password are correct. AniDB Builders will still work but Mature content will not be reachable until this is resolved.") + raise Failed("[CFE0003] Connector Error: AniDB Username/Password could not be verified. Please verify that the username and password are correct. AniDB Builders will still work but Mature content will not be reachable until this is resolved.") self.username = username self.password = password diff --git a/modules/github.py b/modules/github.py index 0a14c2d61..ebd6ebea8 100644 --- a/modules/github.py +++ b/modules/github.py @@ -108,4 +108,4 @@ def translation_yaml(self, translation_key): if k in yaml: output[k] = yaml[k] self._translations[translation_key] = output - return self._translations[translation_key] + return self._translations[translation_key] \ No newline at end of file diff --git a/modules/icheckmovies.py b/modules/icheckmovies.py index c138256f6..644d60bc5 100644 --- a/modules/icheckmovies.py +++ b/modules/icheckmovies.py @@ -27,11 +27,11 @@ def validate_icheckmovies_lists(self, icheckmovies_lists, language): for icheckmovies_list in util.get_list(icheckmovies_lists, split=False): list_url = icheckmovies_list.strip() if not list_url.startswith(base_url): - raise Failed(f"ICheckMovies Error: {list_url} must begin with: {base_url}") + raise Failed(f"[BLE00041] ICheckMovies Error: {list_url} must begin with: {base_url}") elif len(self._parse_list(list_url, language)) > 0: valid_lists.append(list_url) else: - raise Failed(f"ICheckMovies Error: {list_url} failed to parse") + raise Failed(f"[BLE00042] ICheckMovies Error: {list_url} failed to parse") return valid_lists def get_imdb_ids(self, method, data, language): @@ -39,4 +39,4 @@ def get_imdb_ids(self, method, data, language): logger.info(f"Processing ICheckMovies List: {data}") return self._parse_list(data, language) else: - raise Failed(f"ICheckMovies Error: Method {method} not supported") + raise Failed(f"[BLE00043] ICheckMovies Error: Method {method} not supported") diff --git a/modules/letterboxd.py b/modules/letterboxd.py index 6ff40ad9a..4273294a3 100644 --- a/modules/letterboxd.py +++ b/modules/letterboxd.py @@ -59,8 +59,8 @@ def _tmdb(self, letterboxd_url, language): if len(ids) > 0 and ids[0]: if "themoviedb.org/movie" in ids[0]: return util.regex_first_int(ids[0], "TMDb Movie ID") - raise Failed(f"Letterboxd Error: TMDb Movie ID not found in {ids[0]}") - raise Failed(f"Letterboxd Error: TMDb Movie ID not found at {letterboxd_url}") + raise Failed(f"[BLE00022] Letterboxd Error: TMDb Movie ID not found in {ids[0]}") + raise Failed(f"[BLE00023] Letterboxd Error: TMDb Movie ID not found at {letterboxd_url}") def get_user_lists(self, username, sort, language): next_page = [f"/{username}/lists/{sort_options[sort]}"] @@ -142,6 +142,6 @@ def get_tmdb_ids(self, method, data, language): logger.info(f"Filtered: {filtered_ids}") return ids else: - raise Failed(f"Letterboxd Error: No List Items found in {data}") + raise Failed(f"[BLE00024] Letterboxd Error: No List Items found in {data}") else: - raise Failed(f"Letterboxd Error: Method {method} not supported") + raise Failed(f"[BLE00025] Letterboxd Error: Method {method} not supported") diff --git a/modules/mal.py b/modules/mal.py index 1745dae0b..5d6eae49a 100644 --- a/modules/mal.py +++ b/modules/mal.py @@ -96,7 +96,7 @@ def __init__(self, requests, cache, read_only, params): self._authorization() except Exception: logger.stacktrace() - raise Failed("MyAnimeList Error: Failed to Connect") + raise Failed("[CFE0006] Connector Error: MyAnimeList Failed to Connect. Please confirm MyAnimeList is online and reachable.") self._genres = {} self._studios = {} self._delay = None @@ -139,7 +139,7 @@ def _authorization(self): if not url: raise Failed("MyAnimeList Error: No input MyAnimeList code required.") match = re.search("code=([^&]+)", str(url)) if not match: - raise Failed("MyAnimeList Error: Invalid URL") + raise Failed("[CFE0007] Connector Error: MyAnimeList URL specified is invalid. Please check the URL is correct. If you are struggling to authenticate, please try the Online Authenticator at https://kometa.wiki/en/latest/config/authentication/") code = match.group(1) data = { "client_id": self.client_id, @@ -150,9 +150,9 @@ def _authorization(self): } new_authorization = self._oauth(data) if "error" in new_authorization: - raise Failed("MyAnimeList Error: Invalid code") + raise Failed("[CFE0008] Connector Error: MyAnimeList code supplied is invalid. Please try again. If you are struggling to authenticate, please try the Online Authenticator at https://kometa.wiki/en/latest/config/authentication/") if not self._save(new_authorization): - raise Failed("MyAnimeList Error: New Authorization Failed") + raise Failed("[CFE0009] Connector Error: MyAnimeList authorization failed. Please try again. If you are struggling to authenticate, please try the Online Authenticator at https://kometa.wiki/en/latest/config/authentication/") def _check(self, authorization): try: @@ -256,7 +256,7 @@ def _pagination(self, endpoint, params=None, limit=None): if limit is not None: total_items = data["pagination"]["items"]["total"] if total_items == 0: - raise Failed("MyAnimeList Error: No MyAnimeList IDs for Search") + raise Failed("[BLE00026] MyAnimeList Error: No MyAnimeList IDs for Search") if total_items < limit or limit <= 0: limit = total_items per_page = len(data["data"]) @@ -266,7 +266,7 @@ def _pagination(self, endpoint, params=None, limit=None): while current_page <= last_visible_page: if chances > 6: logger.debug(data) - raise Failed("AniList Error: Connection Failed") + raise Failed("[BLE00027] MyAnimeList Error: Connection Failed") start_num = (current_page - 1) * per_page + 1 end_num = limit if limit and (current_page == last_visible_page or limit < start_num + per_page) else current_page * per_page logger.ghost(f"Parsing Page {current_page}/{last_visible_page} {start_num}-{end_num}") @@ -295,9 +295,9 @@ def get_anime(self, mal_id): try: response = self._jikan_request(f"anime/{mal_id}") except JSONDecodeError: - raise Failed("MyAnimeList Error: JSON Decoding Failed") + raise Failed("[BLE00028] MyAnimeList Error: JSON Decoding Failed") if "data" not in response: - raise Failed(f"MyAnimeList Error: No Anime found for MyAnimeList ID: {mal_id}") + raise Failed(f"[BLE00029] MyAnimeList Error: No Anime found for MyAnimeList ID: {mal_id}") mal = MyAnimeListObj(self, mal_id, response["data"]) if self.cache: self.cache.update_mal(expired, mal_id, mal, self.expiration) @@ -323,7 +323,7 @@ def get_mal_ids(self, method, data): logger.info(f"Processing MyAnimeList UserList: {data['limit']} Anime from {self._username() if data['username'] == '@me' else data['username']}'s {pretty_names[data['status']]} list sorted by {pretty_names[data['sort_by']]}") mal_ids = self._userlist(data["username"], data["status"], data["sort_by"], data["limit"]) else: - raise Failed(f"MyAnimeList Error: Method {method} not supported") + raise Failed(f"[BLE00030] MyAnimeList Error: Method {method} not supported") logger.debug("") logger.debug(f"{len(mal_ids)} MyAnimeList IDs Found") logger.trace(f"IDs: {mal_ids}") diff --git a/modules/mdblist.py b/modules/mdblist.py index 8739d57c4..07601c108 100644 --- a/modules/mdblist.py +++ b/modules/mdblist.py @@ -100,10 +100,10 @@ def add_key(self, apikey, expiration): self.get_item(imdb_id="tt0080684", ignore_cache=True) except LimitReached: - logger.info(f"MDBList API limit exhausted") + logger.warning(f"[CFW0001] Connector Warning: MDBList API limit has been reached. Wait 24 hours or consider upgrading to a higher API limit.") self.limit = True except Failed as fe: - logger.info(f"MDBList API connection failed: {fe}") + logger.error(f"[CFE0010] Connector Error: MDBList API connection failed. Please validate your MDBList API key is valid. Response: {fe}") self.apikey = None raise @@ -144,7 +144,7 @@ def get_item(self, imdb_id=None, tmdb_id=None, tvdb_id=None, is_movie=True, igno params["m"] = "movie" if is_movie else "show" key = f"{'tvm' if is_movie else 'tvs'}{tvdb_id}" else: - raise Failed("MDBList Error: Either IMDb ID, TVDb ID, or TMDb ID and TMDb Type Required") + raise Failed("[BLE00031] MDBList Error: Either IMDb ID, TVDb ID, or TMDb ID and TMDb Type required") expired = None if self.cache and not ignore_cache: mdb_dict, expired = self.cache.query_mdb(key, self.expiration) @@ -172,17 +172,17 @@ def validate_mdblist_lists(self, error_type, mdb_lists): mdb_dict = {"url": mdb_dict} dict_methods = {dm.lower(): dm for dm in mdb_dict} if "url" not in dict_methods: - raise Failed(f"{error_type} Error: mdb_list url attribute not found") + raise Failed(f"[BLE00032] MDBList Error: {error_type} mdb_list url attribute not found") elif mdb_dict[dict_methods["url"]] is None: - raise Failed(f"{error_type} Error: mdb_list url attribute is blank") + raise Failed(f"[BLE00033] MDBList Error: {error_type} mdb_list url attribute is blank") else: mdb_url = mdb_dict[dict_methods["url"]].strip() if not mdb_url.startswith(base_url): - raise Failed(f"{error_type} Error: {mdb_url} must begin with: {base_url}") + raise Failed(f"[BLE00034] MDBList Error: {error_type} {mdb_url} must begin with {base_url}") list_count = None if "limit" in dict_methods: if mdb_dict[dict_methods["limit"]] is None: - logger.warning(f"{error_type} Warning: mdb_list limit attribute is blank using 0 as default") + logger.warning(f"[BLW0003] MDBList Warning: {error_type} mdb_list limit attribute is blank using 0 as default") else: try: value = int(str(mdb_dict[dict_methods["limit"]])) @@ -191,18 +191,18 @@ def validate_mdblist_lists(self, error_type, mdb_lists): except ValueError: pass if list_count is None: - logger.warning(f"{error_type} Warning: mdb_list limit attribute must be an integer 0 or greater using 0 as default") + logger.warning(f"[BLW0004] MDBList Warning: {error_type} mdb_list limit attribute must be an integer 0 or greater using 0 as default") if list_count is None: list_count = 0 sort_by = "rank.asc" if "sort_by" in dict_methods: if mdb_dict[dict_methods["sort_by"]] is None: - logger.warning(f"{error_type} Warning: mdb_list sort_by attribute is blank using score as default") + logger.warning(f"[BLW0005] MDBList Warning: {error_type} mdb_list sort_by attribute is blank using score as default") elif mdb_dict[dict_methods["sort_by"]].lower() in sort_names: - logger.warning(f"{error_type} Warning: mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} is missing .desc or .asc defaulting to .desc") + logger.warning(f"[BLW0006] MDBList Warning: {error_type} mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} is missing .desc or .asc defaulting to .desc") sort_by = f"{mdb_dict[dict_methods['sort_by']].lower()}.desc" elif mdb_dict[dict_methods["sort_by"]].lower() not in list_sorts: - logger.warning(f"{error_type} Warning: mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} not valid score as default. Options: {', '.join(list_sorts)}") + logger.warning(f"[BLW0007] MDBList Warning: {error_type} mdb_list sort_by attribute {mdb_dict[dict_methods['sort_by']]} not valid score as default. Options: {', '.join(list_sorts)}") else: sort_by = mdb_dict[dict_methods["sort_by"]].lower() valid_lists.append({"url": mdb_url, "limit": list_count, "sort_by": sort_by}) @@ -228,14 +228,14 @@ def get_tmdb_ids(self, method, data, is_movie=None): if (isinstance(response, dict) and "error" in response) or (isinstance(response, list) and response and "error" in response[0]): err = response["error"] if isinstance(response, dict) else response[0]["error"] if err in ["empty", "empty or private list"]: - raise Failed(f"MDBList Error: No Items Returned. Lists can take 24 hours to update so try again later.") - raise Failed(f"MDBList Error: Invalid Response {response}") + raise Failed(f"[BLE00035] MDBList Error: No Items Returned. Lists can take 24 hours to update so try again later.") + raise Failed(f"[BLE00036] MDBList Error: Invalid Response {response}") results = [] for item in response: if item["mediatype"] in ["movie", "show"] and item["id"]: results.append((item["id"], "tmdb" if item["mediatype"] == "movie" else "tmdb_show")) return results except JSONDecodeError: - raise Failed(f"MDBList Error: Invalid JSON Response received") + raise Failed(f"[BLE00037] MDBList Error: Invalid JSON Response received") else: - raise Failed(f"MDBList Error: Method {method} not supported") + raise Failed(f"[BLE00038] MDBList Error: Method {method} not supported") diff --git a/modules/mojo.py b/modules/mojo.py index 61a7e747a..8612c5c9e 100644 --- a/modules/mojo.py +++ b/modules/mojo.py @@ -187,7 +187,7 @@ def _imdb(self, url): response = self._request(url) imdb_url = response.xpath("//select[@id='releasegroup-picker-navSelector']/option[text()='All Releases']/@value") if not imdb_url: - raise Failed(f"Mojo Error: IMDb ID not found at {base_url}{url}") + raise Failed(f"[BLE00039] BoxOfficeMojo Error: IMDb ID not found at {base_url}{url}") return imdb_url[0][7:-1] def get_imdb_ids(self, method, data): @@ -249,7 +249,7 @@ def get_imdb_ids(self, method, data): logger.info(f"Processing {method.replace('_', ' ').title()}: {text}") items = self._parse_list(url, params, data["limit"]) if not items: - raise Failed(f"Mojo Error: No List Items found in {method}: {data}") + raise Failed(f"[BLE00040] BoxOfficeMojo Error: No List Items found in {method}: {data}") ids = [] total_items = len(items) for i, item in enumerate(items, 1): diff --git a/modules/notifiarr.py b/modules/notifiarr.py index 43469c094..a4b91e7b2 100644 --- a/modules/notifiarr.py +++ b/modules/notifiarr.py @@ -27,10 +27,10 @@ def _request(self, json=None, path="notification", params=None): except JSONDecodeError as e: logger.debug(f"Content: {response.content}") logger.error(e) - raise Failed("Notifiarr Error: Invalid JSON response received") + raise Failed("[CFE0011] Connector Error: Invalid Notifiarr JSON response received") if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"): logger.debug(f"Response: {response_json}") raise Failed(f"({response.status_code} [{response.reason}]) {response_json}") if not response_json["details"]["response"]: - raise Failed("Notifiarr Error: Invalid apikey") + raise Failed("[CFE0012] Connector Error: Invalid Notifiarr API key.") return response From 74810c6be3e71e9806b93ded819c70b51e96e770 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 9 Jan 2025 15:04:39 +0000 Subject: [PATCH 5/7] group-errors Part: 2 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index d00491fd7..0cfbf0888 100644 --- a/PART +++ b/PART @@ -1 +1 @@ -1 +2 From ccfa3851124d7226f230e7a971f841eb92c0cbb1 Mon Sep 17 00:00:00 2001 From: Yozora Date: Thu, 9 Jan 2025 15:29:30 +0000 Subject: [PATCH 6/7] fix some error codes --- modules/icheckmovies.py | 6 +++--- modules/imdb.py | 4 ++-- modules/letterboxd.py | 8 ++++---- modules/mal.py | 10 +++++----- modules/mdblist.py | 16 ++++++++-------- modules/mojo.py | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/icheckmovies.py b/modules/icheckmovies.py index 644d60bc5..73c93bd99 100644 --- a/modules/icheckmovies.py +++ b/modules/icheckmovies.py @@ -27,11 +27,11 @@ def validate_icheckmovies_lists(self, icheckmovies_lists, language): for icheckmovies_list in util.get_list(icheckmovies_lists, split=False): list_url = icheckmovies_list.strip() if not list_url.startswith(base_url): - raise Failed(f"[BLE00041] ICheckMovies Error: {list_url} must begin with: {base_url}") + raise Failed(f"[BLE0041] ICheckMovies Error: {list_url} must begin with: {base_url}") elif len(self._parse_list(list_url, language)) > 0: valid_lists.append(list_url) else: - raise Failed(f"[BLE00042] ICheckMovies Error: {list_url} failed to parse") + raise Failed(f"[BLE0042] ICheckMovies Error: {list_url} failed to parse") return valid_lists def get_imdb_ids(self, method, data, language): @@ -39,4 +39,4 @@ def get_imdb_ids(self, method, data, language): logger.info(f"Processing ICheckMovies List: {data}") return self._parse_list(data, language) else: - raise Failed(f"[BLE00043] ICheckMovies Error: Method {method} not supported") + raise Failed(f"[BLE0043] ICheckMovies Error: Method {method} not supported") diff --git a/modules/imdb.py b/modules/imdb.py index fc704c4dd..fa182c18e 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -537,7 +537,7 @@ def parental_guide(self, imdb_id, ignore_cache=False): def _ids_from_chart(self, chart, language): if chart not in chart_urls: - raise Failed(f"[BLE00020] IMDb Error: chart: {chart} not ") + raise Failed(f"[BLE0020] IMDb Error: chart: {chart} not ") script_data = self._request(f"{base_url}/{chart_urls[chart]}", language=language, xpath="//script[@id='__NEXT_DATA__']/text()")[0] return [x.group(1) for x in re.finditer(r'"(tt\d+)"', script_data)] @@ -571,7 +571,7 @@ def get_imdb_ids(self, method, data, language): logger.info(f" {k}: {v}") return [(_i, "imdb") for _i in self._pagination(data, "search")] else: - raise Failed(f"[BLE00021] IMDb Error: Method {method} not supported") + raise Failed(f"[BLE0021] IMDb Error: Method {method} not supported") def _interface(self, interface): gz = os.path.join(self.default_dir, f"title.{interface}.tsv.gz") diff --git a/modules/letterboxd.py b/modules/letterboxd.py index 4273294a3..eeaad516d 100644 --- a/modules/letterboxd.py +++ b/modules/letterboxd.py @@ -59,8 +59,8 @@ def _tmdb(self, letterboxd_url, language): if len(ids) > 0 and ids[0]: if "themoviedb.org/movie" in ids[0]: return util.regex_first_int(ids[0], "TMDb Movie ID") - raise Failed(f"[BLE00022] Letterboxd Error: TMDb Movie ID not found in {ids[0]}") - raise Failed(f"[BLE00023] Letterboxd Error: TMDb Movie ID not found at {letterboxd_url}") + raise Failed(f"[BLE0022] Letterboxd Error: TMDb Movie ID not found in {ids[0]}") + raise Failed(f"[BLE0023] Letterboxd Error: TMDb Movie ID not found at {letterboxd_url}") def get_user_lists(self, username, sort, language): next_page = [f"/{username}/lists/{sort_options[sort]}"] @@ -142,6 +142,6 @@ def get_tmdb_ids(self, method, data, language): logger.info(f"Filtered: {filtered_ids}") return ids else: - raise Failed(f"[BLE00024] Letterboxd Error: No List Items found in {data}") + raise Failed(f"[BLE0024] Letterboxd Error: No List Items found in {data}") else: - raise Failed(f"[BLE00025] Letterboxd Error: Method {method} not supported") + raise Failed(f"[BLE0025] Letterboxd Error: Method {method} not supported") diff --git a/modules/mal.py b/modules/mal.py index 5d6eae49a..09306fda4 100644 --- a/modules/mal.py +++ b/modules/mal.py @@ -256,7 +256,7 @@ def _pagination(self, endpoint, params=None, limit=None): if limit is not None: total_items = data["pagination"]["items"]["total"] if total_items == 0: - raise Failed("[BLE00026] MyAnimeList Error: No MyAnimeList IDs for Search") + raise Failed("[BLE0026] MyAnimeList Error: No MyAnimeList IDs for Search") if total_items < limit or limit <= 0: limit = total_items per_page = len(data["data"]) @@ -266,7 +266,7 @@ def _pagination(self, endpoint, params=None, limit=None): while current_page <= last_visible_page: if chances > 6: logger.debug(data) - raise Failed("[BLE00027] MyAnimeList Error: Connection Failed") + raise Failed("[BLE0027] MyAnimeList Error: Connection Failed") start_num = (current_page - 1) * per_page + 1 end_num = limit if limit and (current_page == last_visible_page or limit < start_num + per_page) else current_page * per_page logger.ghost(f"Parsing Page {current_page}/{last_visible_page} {start_num}-{end_num}") @@ -295,9 +295,9 @@ def get_anime(self, mal_id): try: response = self._jikan_request(f"anime/{mal_id}") except JSONDecodeError: - raise Failed("[BLE00028] MyAnimeList Error: JSON Decoding Failed") + raise Failed("[BLE0028] MyAnimeList Error: JSON Decoding Failed") if "data" not in response: - raise Failed(f"[BLE00029] MyAnimeList Error: No Anime found for MyAnimeList ID: {mal_id}") + raise Failed(f"[BLE0029] MyAnimeList Error: No Anime found for MyAnimeList ID: {mal_id}") mal = MyAnimeListObj(self, mal_id, response["data"]) if self.cache: self.cache.update_mal(expired, mal_id, mal, self.expiration) @@ -323,7 +323,7 @@ def get_mal_ids(self, method, data): logger.info(f"Processing MyAnimeList UserList: {data['limit']} Anime from {self._username() if data['username'] == '@me' else data['username']}'s {pretty_names[data['status']]} list sorted by {pretty_names[data['sort_by']]}") mal_ids = self._userlist(data["username"], data["status"], data["sort_by"], data["limit"]) else: - raise Failed(f"[BLE00030] MyAnimeList Error: Method {method} not supported") + raise Failed(f"[BLE0030] MyAnimeList Error: Method {method} not supported") logger.debug("") logger.debug(f"{len(mal_ids)} MyAnimeList IDs Found") logger.trace(f"IDs: {mal_ids}") diff --git a/modules/mdblist.py b/modules/mdblist.py index 07601c108..45effe62c 100644 --- a/modules/mdblist.py +++ b/modules/mdblist.py @@ -144,7 +144,7 @@ def get_item(self, imdb_id=None, tmdb_id=None, tvdb_id=None, is_movie=True, igno params["m"] = "movie" if is_movie else "show" key = f"{'tvm' if is_movie else 'tvs'}{tvdb_id}" else: - raise Failed("[BLE00031] MDBList Error: Either IMDb ID, TVDb ID, or TMDb ID and TMDb Type required") + raise Failed("[BLE0031] MDBList Error: Either IMDb ID, TVDb ID, or TMDb ID and TMDb Type required") expired = None if self.cache and not ignore_cache: mdb_dict, expired = self.cache.query_mdb(key, self.expiration) @@ -172,13 +172,13 @@ def validate_mdblist_lists(self, error_type, mdb_lists): mdb_dict = {"url": mdb_dict} dict_methods = {dm.lower(): dm for dm in mdb_dict} if "url" not in dict_methods: - raise Failed(f"[BLE00032] MDBList Error: {error_type} mdb_list url attribute not found") + raise Failed(f"[BLE0032] MDBList Error: {error_type} mdb_list url attribute not found") elif mdb_dict[dict_methods["url"]] is None: - raise Failed(f"[BLE00033] MDBList Error: {error_type} mdb_list url attribute is blank") + raise Failed(f"[BLE0033] MDBList Error: {error_type} mdb_list url attribute is blank") else: mdb_url = mdb_dict[dict_methods["url"]].strip() if not mdb_url.startswith(base_url): - raise Failed(f"[BLE00034] MDBList Error: {error_type} {mdb_url} must begin with {base_url}") + raise Failed(f"[BLE0034] MDBList Error: {error_type} {mdb_url} must begin with {base_url}") list_count = None if "limit" in dict_methods: if mdb_dict[dict_methods["limit"]] is None: @@ -228,14 +228,14 @@ def get_tmdb_ids(self, method, data, is_movie=None): if (isinstance(response, dict) and "error" in response) or (isinstance(response, list) and response and "error" in response[0]): err = response["error"] if isinstance(response, dict) else response[0]["error"] if err in ["empty", "empty or private list"]: - raise Failed(f"[BLE00035] MDBList Error: No Items Returned. Lists can take 24 hours to update so try again later.") - raise Failed(f"[BLE00036] MDBList Error: Invalid Response {response}") + raise Failed(f"[BLE0035] MDBList Error: No Items Returned. Lists can take 24 hours to update so try again later.") + raise Failed(f"[BLE0036] MDBList Error: Invalid Response {response}") results = [] for item in response: if item["mediatype"] in ["movie", "show"] and item["id"]: results.append((item["id"], "tmdb" if item["mediatype"] == "movie" else "tmdb_show")) return results except JSONDecodeError: - raise Failed(f"[BLE00037] MDBList Error: Invalid JSON Response received") + raise Failed(f"[BLE0037] MDBList Error: Invalid JSON Response received") else: - raise Failed(f"[BLE00038] MDBList Error: Method {method} not supported") + raise Failed(f"[BLE0038] MDBList Error: Method {method} not supported") diff --git a/modules/mojo.py b/modules/mojo.py index 8612c5c9e..6fd34d2de 100644 --- a/modules/mojo.py +++ b/modules/mojo.py @@ -187,7 +187,7 @@ def _imdb(self, url): response = self._request(url) imdb_url = response.xpath("//select[@id='releasegroup-picker-navSelector']/option[text()='All Releases']/@value") if not imdb_url: - raise Failed(f"[BLE00039] BoxOfficeMojo Error: IMDb ID not found at {base_url}{url}") + raise Failed(f"[BLE0039] BoxOfficeMojo Error: IMDb ID not found at {base_url}{url}") return imdb_url[0][7:-1] def get_imdb_ids(self, method, data): @@ -249,7 +249,7 @@ def get_imdb_ids(self, method, data): logger.info(f"Processing {method.replace('_', ' ').title()}: {text}") items = self._parse_list(url, params, data["limit"]) if not items: - raise Failed(f"[BLE00040] BoxOfficeMojo Error: No List Items found in {method}: {data}") + raise Failed(f"[BLE0040] BoxOfficeMojo Error: No List Items found in {method}: {data}") ids = [] total_items = len(items) for i, item in enumerate(items, 1): From 2b79a2fb93da0fc93d39ce7423892490ac157b52 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 9 Jan 2025 15:31:10 +0000 Subject: [PATCH 7/7] group-errors Part: 3 --- PART | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PART b/PART index 0cfbf0888..00750edc0 100644 --- a/PART +++ b/PART @@ -1 +1 @@ -2 +3