From 4d014c9512d84b1299263b6cb3382402ca6e40fe Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 17 Apr 2022 13:40:23 -0400 Subject: [PATCH] [1] minor fixes --- VERSION | 2 +- modules/config.py | 1 + modules/mdblist.py | 5 ++++- modules/meta.py | 10 ++++------ modules/util.py | 3 ++- modules/webhooks.py | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 0d92a102..dc022bd8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5 +1.16.5-develop1 diff --git a/modules/config.py b/modules/config.py index 78c10dab..b2608026 100644 --- a/modules/config.py +++ b/modules/config.py @@ -62,6 +62,7 @@ class ConfigFile: elif os.path.exists(os.path.join(default_dir, "config.yml")): self.config_path = os.path.abspath(os.path.join(default_dir, "config.yml")) else: raise Failed(f"Config Error: config not found at {os.path.abspath(default_dir)}") logger.info(f"Using {self.config_path} as config") + logger.clear_errors() self.default_dir = default_dir self.read_only = attrs["read_only"] if "read_only" in attrs else False diff --git a/modules/mdblist.py b/modules/mdblist.py index f1ab799c..0c8f577d 100644 --- a/modules/mdblist.py +++ b/modules/mdblist.py @@ -173,7 +173,10 @@ class Mdblist: url_base = url_base if url_base.endswith("/") else f"{url_base}/" url_base = url_base if url_base.endswith("json/") else f"{url_base}json/" try: - return [(i["imdb_id"], "imdb") for i in self.config.get_json(url_base, headers=headers, params=params)] + response = self.config.get_json(url_base, headers=headers, params=params) + if "error" in response: + raise Failed(f"Mdblist Error: Invalid Response {response}") + return [(i["imdb_id"], "imdb") for i in response] except JSONDecodeError: raise Failed(f"Mdblist Error: Invalid Response") else: diff --git a/modules/meta.py b/modules/meta.py index 936b97c6..a1a1f0a2 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -7,8 +7,6 @@ from ruamel import yaml logger = util.logger -github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/" - all_auto = ["genre"] ms_auto = [ "actor", "year", "content_rating", "original_language", "tmdb_popular_people", "trakt_user_lists", "studio", @@ -70,7 +68,7 @@ class DataFile: self.templates = {} def get_file_name(self): - data = f"{github_base}{self.path}.yml" if self.type == "GIT" else self.path + data = f"{util.github_base}{self.path}.yml" if self.type == "GIT" else self.path if "/" in data: return data[data.rfind("/") + 1:-4] elif "\\" in data: @@ -83,7 +81,7 @@ class DataFile: if file_type in ["URL", "Git", "Repo"]: if file_type == "Repo" and not self.config.custom_repo: raise Failed("Config Error: No custom_repo defined") - content_path = file_path if file_type == "URL" else f"{self.config.custom_repo if file_type == 'Repo' else github_base}{file_path}.yml" + content_path = file_path if file_type == "URL" else f"{self.config.custom_repo if file_type == 'Repo' else util.github_base}{file_path}.yml" response = self.config.get(content_path) if response.status_code >= 400: raise Failed(f"URL Error: No file found at {content_path}") @@ -427,12 +425,12 @@ class MetadataFile(DataFile): roles = [data for _, data in people.items()] roles.sort(key=operator.itemgetter('count'), reverse=True) if not person_minimum: - person_minimum = 0 if person_limit else 3 + person_minimum = 1 if person_limit else 3 if not person_limit: person_limit = len(roles) person_count = 0 for role in roles: - if person_count < person_limit and role["count"] > person_minimum and role["name"] not in exclude: + if person_count < person_limit and role["count"] >= person_minimum and role["name"] not in exclude: auto_list[role["name"]] = role["name"] all_keys.append(role["name"]) person_count += 1 diff --git a/modules/util.py b/modules/util.py index b7e05718..d8eec25f 100644 --- a/modules/util.py +++ b/modules/util.py @@ -82,6 +82,7 @@ collection_mode_options = { "hide_items": "hideItems", "hideitems": "hideItems", "show_items": "showItems", "showitems": "showItems" } +github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/" def tab_new_lines(data): return str(data).replace("\n", "\n ") if "\n" in str(data) else str(data) @@ -556,7 +557,7 @@ def parse(error, attribute, data, datatype=None, methods=None, parent=None, defa return f"{start}{range_split}{end}" else: value = check_int(value, datatype=datatype, minimum=minimum, maximum=maximum) - if value: + if value is not None: return value message = f"{display} {value} must {'each ' if range_split else ''}be {'an integer' if datatype == 'int' else 'a number'}" message = f"{message} {minimum} or greater" if maximum is None else f"{message} between {minimum} and {maximum}" diff --git a/modules/webhooks.py b/modules/webhooks.py index e77d94fa..c48dcfd6 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -16,7 +16,7 @@ class Webhooks: def _request(self, webhooks, json): if self.config.trace_mode: - logger.separator("Webhooks", space=False, border=False) + logger.separator("Webhooks", space=False, border=False, debug=True) logger.debug("") logger.debug(f"JSON: {json}") for webhook in list(set(webhooks)):