mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-25 22:10:22 +00:00
added debugs
This commit is contained in:
parent
306102d0ee
commit
4b3056f22d
3 changed files with 29 additions and 55 deletions
|
@ -296,7 +296,7 @@ class CollectionBuilder:
|
|||
if run_time.startswith("hour"):
|
||||
try:
|
||||
if 0 <= int(param) <= 23:
|
||||
self.schedule += f"\nScheduled to run only on the {util.make_ordinal(param)} hour"
|
||||
self.schedule += f"\nScheduled to run only on the {util.make_ordinal(int(param))} hour"
|
||||
if self.config.run_hour == int(param):
|
||||
skip_collection = False
|
||||
else:
|
||||
|
@ -314,7 +314,7 @@ class CollectionBuilder:
|
|||
elif run_time.startswith("month"):
|
||||
try:
|
||||
if 1 <= int(param) <= 31:
|
||||
self.schedule += f"\nScheduled monthly on the {util.make_ordinal(param)}"
|
||||
self.schedule += f"\nScheduled monthly on the {util.make_ordinal(int(param))}"
|
||||
if self.current_time.day == int(param) or (self.current_time.day == last_day.day and int(param) > last_day.day):
|
||||
skip_collection = False
|
||||
else:
|
||||
|
@ -349,7 +349,7 @@ class CollectionBuilder:
|
|||
logger.warning(f"Collection Warning: run_again attribute is blank defaulting to false")
|
||||
else:
|
||||
logger.debug(f"Value: {self.data[methods['run_again']]}")
|
||||
self.run_again = util.get_bool("run_again", self.data[methods["run_again"]])
|
||||
self.run_again = util.parse_bool("run_again", self.data[methods["run_again"]])
|
||||
|
||||
self.sync = self.library.sync_mode == "sync"
|
||||
if "sync_mode" in methods:
|
||||
|
@ -372,7 +372,7 @@ class CollectionBuilder:
|
|||
logger.warning(f"Collection Warning: build_collection attribute is blank defaulting to true")
|
||||
else:
|
||||
logger.debug(f"Value: {self.data[methods['build_collection']]}")
|
||||
self.build_collection = util.get_bool("build_collection", self.data[methods["build_collection"]])
|
||||
self.build_collection = util.parse_bool("build_collection", self.data[methods["build_collection"]])
|
||||
|
||||
if "tmdb_person" in methods:
|
||||
logger.info("")
|
||||
|
@ -596,7 +596,7 @@ class CollectionBuilder:
|
|||
else:
|
||||
self.details[method_final] = util.get_list(method_data)
|
||||
elif method_name in boolean_details:
|
||||
self.details[method_name] = util.get_bool(method_name, method_data)
|
||||
self.details[method_name] = util.parse_bool(method_name, method_data)
|
||||
elif method_name in string_details:
|
||||
self.details[method_name] = str(method_data)
|
||||
|
||||
|
@ -638,11 +638,11 @@ class CollectionBuilder:
|
|||
|
||||
def _radarr(self, method_name, method_data):
|
||||
if method_name == "radarr_add":
|
||||
self.add_to_radarr = util.get_bool(method_name, method_data)
|
||||
self.add_to_radarr = util.parse_bool(method_name, method_data)
|
||||
elif method_name == "radarr_folder":
|
||||
self.radarr_options["folder"] = method_data
|
||||
elif method_name in ["radarr_monitor", "radarr_search"]:
|
||||
self.radarr_options[method_name[7:]] = util.get_bool(method_name, method_data)
|
||||
self.radarr_options[method_name[7:]] = util.parse_bool(method_name, method_data)
|
||||
elif method_name == "radarr_availability":
|
||||
if str(method_data).lower() in radarr.availability_translation:
|
||||
self.radarr_options["availability"] = str(method_data).lower()
|
||||
|
@ -656,7 +656,7 @@ class CollectionBuilder:
|
|||
|
||||
def _sonarr(self, method_name, method_data):
|
||||
if method_name == "sonarr_add":
|
||||
self.add_to_sonarr = util.get_bool(method_name, method_data)
|
||||
self.add_to_sonarr = util.parse_bool(method_name, method_data)
|
||||
elif method_name == "sonarr_folder":
|
||||
self.sonarr_options["folder"] = method_data
|
||||
elif method_name == "sonarr_monitor":
|
||||
|
@ -676,7 +676,7 @@ class CollectionBuilder:
|
|||
else:
|
||||
raise Failed(f"Collection Error: {method_name} attribute must be either standard, daily, or anime")
|
||||
elif method_name in ["sonarr_season", "sonarr_search", "sonarr_cutoff_search"]:
|
||||
self.sonarr_options[method_name[7:]] = util.get_bool(method_name, method_data)
|
||||
self.sonarr_options[method_name[7:]] = util.parse_bool(method_name, method_data)
|
||||
elif method_name == "sonarr_tag":
|
||||
self.sonarr_options["tag"] = util.get_list(method_data)
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ class CollectionBuilder:
|
|||
elif attribute in ["decade", "year", "episode_year"] and modifier in ["", ".not"]:
|
||||
return smart_pair(util.get_year_list(data, self.current_year, final))
|
||||
elif attribute in plex.boolean_attributes:
|
||||
return util.get_bool(attribute, data)
|
||||
return util.parse_bool(attribute, data)
|
||||
else:
|
||||
raise Failed(f"Collection Error: {final} attribute not supported")
|
||||
|
||||
|
|
|
@ -376,6 +376,10 @@ class Plex:
|
|||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
||||
def _upload_image(self, item, image):
|
||||
logger.debug(item)
|
||||
logger.debug(image.is_poster)
|
||||
logger.debug(image.is_url)
|
||||
logger.debug(image.location)
|
||||
if image.is_poster and image.is_url:
|
||||
item.uploadPoster(url=image.location)
|
||||
elif image.is_poster:
|
||||
|
@ -388,6 +392,8 @@ class Plex:
|
|||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
||||
def upload_file_poster(self, item, image):
|
||||
logger.debug(item)
|
||||
logger.debug(image)
|
||||
item.uploadPoster(filepath=image)
|
||||
self.reload(item)
|
||||
|
||||
|
@ -546,13 +552,13 @@ class Plex:
|
|||
|
||||
def get_collection(self, data):
|
||||
if isinstance(data, int):
|
||||
collection = self.fetchItem(data)
|
||||
return self.fetchItem(data)
|
||||
elif isinstance(data, Collection):
|
||||
collection = data
|
||||
return data
|
||||
else:
|
||||
collection = util.choose_from_list(self.search(title=str(data), libtype="collection"), "collection", str(data), exact=True)
|
||||
if collection:
|
||||
return collection
|
||||
for d in self.search(title=str(data), libtype="collection"):
|
||||
if d.title == data:
|
||||
return d
|
||||
raise Failed(f"Plex Error: Collection {data} not found")
|
||||
|
||||
def validate_collections(self, collections):
|
||||
|
@ -689,7 +695,10 @@ class Plex:
|
|||
kwargs = {}
|
||||
if year is not None:
|
||||
kwargs["year"] = year
|
||||
return util.choose_from_list(self.search(title=str(data), **kwargs), "movie" if self.is_movie else "show", str(data), exact=True)
|
||||
for d in self.search(title=str(data), **kwargs):
|
||||
if d.title == data:
|
||||
return d
|
||||
return None
|
||||
|
||||
def edit_item(self, item, name, item_type, edits, advanced=False):
|
||||
if len(edits) > 0:
|
||||
|
|
|
@ -93,48 +93,13 @@ def tab_new_lines(data):
|
|||
return str(data).replace("\n", "\n|\t ") if "\n" in str(data) else str(data)
|
||||
|
||||
def make_ordinal(n):
|
||||
n = int(n)
|
||||
suffix = ["th", "st", "nd", "rd", "th"][min(n % 10, 4)]
|
||||
if 11 <= (n % 100) <= 13:
|
||||
suffix = "th"
|
||||
return str(n) + suffix
|
||||
return f"{n}{'th' if 11 <= (n % 100) <= 13 else ['th', 'st', 'nd', 'rd', 'th'][min(n % 10, 4)]}"
|
||||
|
||||
def choose_from_list(datalist, description, data=None, list_type="title", exact=False):
|
||||
if len(datalist) > 0:
|
||||
if len(datalist) == 1 and (description != "collection" or datalist[0].title == data):
|
||||
return datalist[0]
|
||||
zero_option = f"Create New Collection: {data}" if description == "collection" else "Do Nothing"
|
||||
message = f"Multiple {description}s Found\n0) {zero_option}"
|
||||
for i, d in enumerate(datalist, 1):
|
||||
if list_type == "title":
|
||||
if d.title == data:
|
||||
return d
|
||||
message += f"\n{i}) {d.title}"
|
||||
else:
|
||||
message += f"\n{i}) [{d[0]}] {d[1]}"
|
||||
if exact:
|
||||
return None
|
||||
print_multiline(message, info=True)
|
||||
while True:
|
||||
try:
|
||||
selection = int(logger_input(f"Choose {description} number")) - 1
|
||||
if selection >= 0: return datalist[selection]
|
||||
elif selection == -1: return None
|
||||
else: logger.info(f"Invalid {description} number")
|
||||
except IndexError: logger.info(f"Invalid {description} number")
|
||||
except TimeoutExpired:
|
||||
if list_type == "title":
|
||||
logger.warning(f"Input Timeout: using {data}")
|
||||
return None
|
||||
else:
|
||||
logger.warning(f"Input Timeout: using {datalist[0][1]}")
|
||||
return datalist[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_bool(method_name, method_data):
|
||||
def parse_bool(method_name, method_data):
|
||||
if isinstance(method_data, bool):
|
||||
return method_data
|
||||
elif isinstance(method_data, int):
|
||||
return method_data > 0
|
||||
elif str(method_data).lower() in ["t", "true"]:
|
||||
return True
|
||||
elif str(method_data).lower() in ["f", "false"]:
|
||||
|
|
Loading…
Reference in a new issue