|
|
@ -220,11 +220,14 @@ class CollectionBuilder:
|
|
|
|
methods = {m.lower(): m for m in self.data}
|
|
|
|
methods = {m.lower(): m for m in self.data}
|
|
|
|
|
|
|
|
|
|
|
|
if "template" in methods:
|
|
|
|
if "template" in methods:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: template")
|
|
|
|
if not self.metadata.templates:
|
|
|
|
if not self.metadata.templates:
|
|
|
|
raise Failed("Collection Error: No templates found")
|
|
|
|
raise Failed("Collection Error: No templates found")
|
|
|
|
elif not self.data[methods["template"]]:
|
|
|
|
elif not self.data[methods["template"]]:
|
|
|
|
raise Failed("Collection Error: template attribute is blank")
|
|
|
|
raise Failed("Collection Error: template attribute is blank")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['template']]}")
|
|
|
|
for variables in util.get_list(self.data[methods["template"]], split=False):
|
|
|
|
for variables in util.get_list(self.data[methods["template"]], split=False):
|
|
|
|
if not isinstance(variables, dict):
|
|
|
|
if not isinstance(variables, dict):
|
|
|
|
raise Failed("Collection Error: template attribute is not a dictionary")
|
|
|
|
raise Failed("Collection Error: template attribute is not a dictionary")
|
|
|
@ -329,13 +332,14 @@ class CollectionBuilder:
|
|
|
|
except Failed:
|
|
|
|
except Failed:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
skip_collection = True
|
|
|
|
if "schedule" in methods:
|
|
|
|
if "schedule" not in methods:
|
|
|
|
logger.info("")
|
|
|
|
skip_collection = False
|
|
|
|
logger.info("Validating Method: schedule")
|
|
|
|
elif not self.data[methods["schedule"]]:
|
|
|
|
if not self.data[methods["schedule"]]:
|
|
|
|
logger.error("Collection Error: schedule attribute is blank. Running daily")
|
|
|
|
raise Failed("Collection Error: schedule attribute is blank")
|
|
|
|
skip_collection = False
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['schedule']]}")
|
|
|
|
|
|
|
|
skip_collection = True
|
|
|
|
schedule_list = util.get_list(self.data[methods["schedule"]])
|
|
|
|
schedule_list = util.get_list(self.data[methods["schedule"]])
|
|
|
|
next_month = current_time.replace(day=28) + timedelta(days=4)
|
|
|
|
next_month = current_time.replace(day=28) + timedelta(days=4)
|
|
|
|
last_day = next_month - timedelta(days=next_month.day)
|
|
|
|
last_day = next_month - timedelta(days=next_month.day)
|
|
|
@ -387,8 +391,46 @@ class CollectionBuilder:
|
|
|
|
self.run_again = "run_again" in methods
|
|
|
|
self.run_again = "run_again" in methods
|
|
|
|
self.collectionless = "plex_collectionless" in methods
|
|
|
|
self.collectionless = "plex_collectionless" in methods
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.run_again = False
|
|
|
|
|
|
|
|
if "run_again" in methods:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: run_again")
|
|
|
|
|
|
|
|
if not self.data[methods["run_again"]]:
|
|
|
|
|
|
|
|
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.sync = self.library.sync_mode == "sync"
|
|
|
|
|
|
|
|
if "sync_mode" in methods:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: sync_mode")
|
|
|
|
|
|
|
|
if not self.data[methods["sync_mode"]]:
|
|
|
|
|
|
|
|
logger.warning(f"Collection Warning: sync_mode attribute is blank using general: {self.library.sync_mode}")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['sync_mode']]}")
|
|
|
|
|
|
|
|
if self.data[methods["sync_mode"]].lower() not in ["append", "sync"]:
|
|
|
|
|
|
|
|
logger.warning(f"Collection Warning: {self.data[methods['sync_mode']]} sync_mode invalid using general: {self.library.sync_mode}")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.sync = self.data[methods["sync_mode"]].lower() == "sync"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.build_collection = True
|
|
|
|
|
|
|
|
if "build_collection" in methods:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: build_collection")
|
|
|
|
|
|
|
|
if not self.data[methods["build_collection"]]:
|
|
|
|
|
|
|
|
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"]])
|
|
|
|
|
|
|
|
|
|
|
|
if "tmdb_person" in methods:
|
|
|
|
if "tmdb_person" in methods:
|
|
|
|
if self.data[methods["tmdb_person"]]:
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: build_collection")
|
|
|
|
|
|
|
|
if not self.data[methods["tmdb_person"]]:
|
|
|
|
|
|
|
|
raise Failed("Collection Error: tmdb_person attribute is blank")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['tmdb_person']]}")
|
|
|
|
valid_names = []
|
|
|
|
valid_names = []
|
|
|
|
for tmdb_id in util.get_int_list(self.data[methods["tmdb_person"]], "TMDb Person ID"):
|
|
|
|
for tmdb_id in util.get_int_list(self.data[methods["tmdb_person"]], "TMDb Person ID"):
|
|
|
|
person = config.TMDb.get_person(tmdb_id)
|
|
|
|
person = config.TMDb.get_person(tmdb_id)
|
|
|
@ -401,43 +443,48 @@ class CollectionBuilder:
|
|
|
|
self.details["tmdb_person"] = valid_names
|
|
|
|
self.details["tmdb_person"] = valid_names
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise Failed(f"Collection Error: No valid TMDb Person IDs in {self.data[methods['tmdb_person']]}")
|
|
|
|
raise Failed(f"Collection Error: No valid TMDb Person IDs in {self.data[methods['tmdb_person']]}")
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise Failed("Collection Error: tmdb_person attribute is blank")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.smart_sort = "random"
|
|
|
|
self.smart_sort = "random"
|
|
|
|
self.smart_label_collection = False
|
|
|
|
self.smart_label_collection = False
|
|
|
|
if "smart_label" in methods:
|
|
|
|
if "smart_label" in methods:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: smart_label")
|
|
|
|
self.smart_label_collection = True
|
|
|
|
self.smart_label_collection = True
|
|
|
|
if self.data[methods["smart_label"]]:
|
|
|
|
if not self.data[methods["smart_label"]]:
|
|
|
|
|
|
|
|
logger.warning("Collection Error: smart_label attribute is blank defaulting to random")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['smart_label']]}")
|
|
|
|
if (self.library.is_movie and str(self.data[methods["smart_label"]]).lower() in plex.movie_smart_sorts) \
|
|
|
|
if (self.library.is_movie and str(self.data[methods["smart_label"]]).lower() in plex.movie_smart_sorts) \
|
|
|
|
or (self.library.is_show and str(self.data[methods["smart_label"]]).lower() in plex.show_smart_sorts):
|
|
|
|
or (self.library.is_show and str(self.data[methods["smart_label"]]).lower() in plex.show_smart_sorts):
|
|
|
|
self.smart_sort = str(self.data[methods["smart_label"]]).lower()
|
|
|
|
self.smart_sort = str(self.data[methods["smart_label"]]).lower()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.warning(f"Collection Error: smart_label attribute: {self.data[methods['smart_label']]} is invalid defaulting to random")
|
|
|
|
logger.warning(f"Collection Error: smart_label attribute: {self.data[methods['smart_label']]} is invalid defaulting to random")
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.warning("Collection Error: smart_label attribute is blank defaulting to random")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.smart_url = None
|
|
|
|
self.smart_url = None
|
|
|
|
self.smart_type_key = None
|
|
|
|
self.smart_type_key = None
|
|
|
|
if "smart_url" in methods:
|
|
|
|
if "smart_url" in methods:
|
|
|
|
if self.data[methods["smart_url"]]:
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: smart_url")
|
|
|
|
|
|
|
|
if not self.data[methods["smart_url"]]:
|
|
|
|
|
|
|
|
raise Failed("Collection Error: smart_url attribute is blank")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['smart_url']]}")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.smart_url, self.smart_type_key = library.get_smart_filter_from_uri(self.data[methods["smart_url"]])
|
|
|
|
self.smart_url, self.smart_type_key = library.get_smart_filter_from_uri(self.data[methods["smart_url"]])
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
raise Failed("Collection Error: smart_url is incorrectly formatted")
|
|
|
|
raise Failed("Collection Error: smart_url is incorrectly formatted")
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise Failed("Collection Error: smart_url attribute is blank")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.smart_filter_details = ""
|
|
|
|
self.smart_filter_details = ""
|
|
|
|
if "smart_filter" in methods:
|
|
|
|
if "smart_filter" in methods:
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info("Validating Method: smart_filter")
|
|
|
|
filter_details = "\n"
|
|
|
|
filter_details = "\n"
|
|
|
|
smart_filter = self.data[methods["smart_filter"]]
|
|
|
|
smart_filter = self.data[methods["smart_filter"]]
|
|
|
|
if smart_filter is None:
|
|
|
|
if smart_filter is None:
|
|
|
|
raise Failed(f"Collection Error: smart_filter attribute is blank")
|
|
|
|
raise Failed(f"Collection Error: smart_filter attribute is blank")
|
|
|
|
if not isinstance(smart_filter, dict):
|
|
|
|
if not isinstance(smart_filter, dict):
|
|
|
|
raise Failed(f"Collection Error: smart_filter must be a dictionary: {smart_filter}")
|
|
|
|
raise Failed(f"Collection Error: smart_filter must be a dictionary: {smart_filter}")
|
|
|
|
|
|
|
|
logger.debug(f"Value: {self.data[methods['smart_filter']]}")
|
|
|
|
smart_methods = {m.lower(): m for m in smart_filter}
|
|
|
|
smart_methods = {m.lower(): m for m in smart_filter}
|
|
|
|
if "any" in smart_methods and "all" in smart_methods:
|
|
|
|
if "any" in smart_methods and "all" in smart_methods:
|
|
|
|
raise Failed(f"Collection Error: Cannot have more then one base")
|
|
|
|
raise Failed(f"Collection Error: Cannot have more then one base")
|
|
|
@ -611,6 +658,10 @@ class CollectionBuilder:
|
|
|
|
self.smart = self.smart_url or self.smart_label_collection
|
|
|
|
self.smart = self.smart_url or self.smart_label_collection
|
|
|
|
|
|
|
|
|
|
|
|
for method_key, method_data in self.data.items():
|
|
|
|
for method_key, method_data in self.data.items():
|
|
|
|
|
|
|
|
if method_key.lower() in ignored_details:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
logger.info(f"Validating Method: {method_key}")
|
|
|
|
if "trakt" in method_key.lower() and not config.Trakt: raise Failed(f"Collection Error: {method_key} requires Trakt todo be configured")
|
|
|
|
if "trakt" in method_key.lower() and not config.Trakt: raise Failed(f"Collection Error: {method_key} requires Trakt todo be configured")
|
|
|
|
elif "imdb" in method_key.lower() and not config.IMDb: raise Failed(f"Collection Error: {method_key} requires TMDb or Trakt to be configured")
|
|
|
|
elif "imdb" in method_key.lower() and not config.IMDb: raise Failed(f"Collection Error: {method_key} requires TMDb or Trakt to be configured")
|
|
|
|
elif "radarr" in method_key.lower() and not self.library.Radarr: raise Failed(f"Collection Error: {method_key} requires Radarr to be configured")
|
|
|
|
elif "radarr" in method_key.lower() and not self.library.Radarr: raise Failed(f"Collection Error: {method_key} requires Radarr to be configured")
|
|
|
@ -618,8 +669,6 @@ class CollectionBuilder:
|
|
|
|
elif "tautulli" in method_key.lower() and not self.library.Tautulli: raise Failed(f"Collection Error: {method_key} requires Tautulli to be configured")
|
|
|
|
elif "tautulli" in method_key.lower() and not self.library.Tautulli: raise Failed(f"Collection Error: {method_key} requires Tautulli to be configured")
|
|
|
|
elif "mal" in method_key.lower() and not config.MyAnimeList: raise Failed(f"Collection Error: {method_key} requires MyAnimeList to be configured")
|
|
|
|
elif "mal" in method_key.lower() and not config.MyAnimeList: raise Failed(f"Collection Error: {method_key} requires MyAnimeList to be configured")
|
|
|
|
elif method_data is not None:
|
|
|
|
elif method_data is not None:
|
|
|
|
logger.debug("")
|
|
|
|
|
|
|
|
logger.debug(f"Validating Method: {method_key}")
|
|
|
|
|
|
|
|
logger.debug(f"Value: {method_data}")
|
|
|
|
logger.debug(f"Value: {method_data}")
|
|
|
|
if method_key.lower() in method_alias:
|
|
|
|
if method_key.lower() in method_alias:
|
|
|
|
method_name = method_alias[method_key.lower()]
|
|
|
|
method_name = method_alias[method_key.lower()]
|
|
|
@ -1226,15 +1275,6 @@ class CollectionBuilder:
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.warning(f"Collection Warning: {method_key} attribute is blank")
|
|
|
|
logger.warning(f"Collection Warning: {method_key} attribute is blank")
|
|
|
|
|
|
|
|
|
|
|
|
self.sync = self.library.sync_mode == "sync"
|
|
|
|
|
|
|
|
if "sync_mode" in methods:
|
|
|
|
|
|
|
|
if not self.data[methods["sync_mode"]]:
|
|
|
|
|
|
|
|
logger.warning(f"Collection Warning: sync_mode attribute is blank using general: {self.library.sync_mode}")
|
|
|
|
|
|
|
|
elif self.data[methods["sync_mode"]].lower() not in ["append", "sync"]:
|
|
|
|
|
|
|
|
logger.warning(f"Collection Warning: {self.data[methods['sync_mode']]} sync_mode invalid using general: {self.library.sync_mode}")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.sync = self.data[methods["sync_mode"]].lower() == "sync"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.add_to_radarr is None:
|
|
|
|
if self.add_to_radarr is None:
|
|
|
|
self.add_to_radarr = self.library.Radarr.add if self.library.Radarr else False
|
|
|
|
self.add_to_radarr = self.library.Radarr.add if self.library.Radarr else False
|
|
|
|
if self.add_to_sonarr is None:
|
|
|
|
if self.add_to_sonarr is None:
|
|
|
@ -1250,13 +1290,6 @@ class CollectionBuilder:
|
|
|
|
self.details["collection_mode"] = "hide"
|
|
|
|
self.details["collection_mode"] = "hide"
|
|
|
|
self.sync = True
|
|
|
|
self.sync = True
|
|
|
|
|
|
|
|
|
|
|
|
self.build_collection = True
|
|
|
|
|
|
|
|
if "build_collection" in methods:
|
|
|
|
|
|
|
|
if not self.data[methods["build_collection"]]:
|
|
|
|
|
|
|
|
logger.warning(f"Collection Warning: build_collection attribute is blank defaulting to true")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.build_collection = util.get_bool("build_collection", self.data[methods["build_collection"]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.build_collection:
|
|
|
|
if self.build_collection:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.obj = library.get_collection(self.name)
|
|
|
|
self.obj = library.get_collection(self.name)
|
|
|
|