removed sort_by and now am overloading collection_order

pull/541/head
meisnate12 3 years ago
parent e0c42c272a
commit 4aa536b27a

@ -434,8 +434,10 @@ class CollectionBuilder:
self.details["collection_order"] = self.data[methods["collection_order"]].lower()
if self.data[methods["collection_order"]].lower() == "custom" and self.build_collection:
self.custom_sort = True
elif (self.library.is_movie and self.data[methods["collection_order"]].lower() in plex.movie_sorts) or (self.library.is_show and self.data[methods["collection_order"]].lower() in plex.show_sorts):
self.custom_sort = self.data[methods["collection_order"]].lower()
else:
raise Failed(f"{self.Type} Error: {self.data[methods['collection_order']]} collection_order invalid\n\trelease (Order Collection by release dates)\n\talpha (Order Collection Alphabetically)\n\tcustom (Custom Order Collection)")
raise Failed(f"{self.Type} Error: {self.data[methods['collection_order']]} collection_order invalid\n\trelease (Order Collection by release dates)\n\talpha (Order Collection Alphabetically)\n\tcustom (Custom Order Collection)\n\tOther sorting options can be found at https://github.com/meisnate12/Plex-Meta-Manager/wiki/Smart-Builders#sort-options")
self.sort_by = None
if "sort_by" in methods and not self.playlist:
@ -596,7 +598,7 @@ class CollectionBuilder:
else:
logger.error(e)
if self.custom_sort and (len(self.builders) > 1 or self.builders[0][0] not in custom_sort_builders):
if self.custom_sort is True and (len(self.builders) > 1 or self.builders[0][0] not in custom_sort_builders):
raise Failed(f"{self.Type} Error: " + ('Playlists' if playlist else 'collection_order: custom') +
(f" can only be used with a single builder per {self.type}" if len(self.builders) > 1 else f" cannot be used with {self.builders[0][0]}"))
@ -2245,11 +2247,11 @@ class CollectionBuilder:
logger.info("")
util.separator(f"Sorting {self.name} {self.Type}", space=False, border=False)
logger.info("")
if self.sort_by:
search_data = self.build_filter("plex_search", {"sort_by": self.sort_by, "any": {"collection": self.name}})
items = self.library.get_filter_items(search_data[2])
else:
if self.custom_sort is True:
items = self.added_items
else:
search_data = self.build_filter("plex_search", {"sort_by": self.custom_sort, "any": {"collection": self.name}})
items = self.library.get_filter_items(search_data[2])
previous = None
for item in items:
text = f"after {util.item_title(previous)}" if previous else "to the beginning"

@ -267,6 +267,7 @@ class ConfigFile:
"test": check_for_attribute(self.data, "test", parent="notifiarr", var_type="bool", default=False, do_print=False, save=False)
})
except Failed as e:
util.print_stacktrace()
logger.error(e)
logger.info(f"Notifiarr Connection {'Failed' if self.NotifiarrFactory is None else 'Successful'}")
else:
@ -567,14 +568,14 @@ class ConfigFile:
if "tmdb_collections" in lib["operations"]:
params["tmdb_collections"] = {
"exclude_ids": [],
"remove_suffix": None,
"remove_suffix": [],
"dictionary_variables": {},
"template": {"tmdb_collection_details": "<<collection_id>>"}
}
if lib["operations"]["tmdb_collections"] and isinstance(lib["operations"]["tmdb_collections"], dict):
params["tmdb_collections"]["exclude_ids"] = check_for_attribute(lib["operations"]["tmdb_collections"], "exclude_ids", var_type="int_list", default_is_none=True, save=False)
params["tmdb_collections"]["remove_suffix"] = check_for_attribute(lib["operations"]["tmdb_collections"], "remove_suffix", default_is_none=True, save=False)
params["tmdb_collections"]["remove_suffix"] = check_for_attribute(lib["operations"]["tmdb_collections"], "remove_suffix", var_type="comma_list", default_is_none=True, save=False)
if "dictionary_variables" in lib["operations"]["tmdb_collections"] and lib["operations"]["tmdb_collections"]["dictionary_variables"] and isinstance(lib["operations"]["tmdb_collections"]["dictionary_variables"], dict):
for key, value in lib["operations"]["tmdb_collections"]["dictionary_variables"].items():
if isinstance(value, dict):
@ -587,8 +588,6 @@ class ConfigFile:
logger.warning("Config Warning: Using default template for tmdb_collections")
else:
logger.error("Config Error: tmdb_collections blank using default settings")
if params["tmdb_collections"]["remove_suffix"]:
params["tmdb_collections"]["remove_suffix"] = params["tmdb_collections"]["remove_suffix"].strip()
if "genre_mapper" in lib["operations"]:
if lib["operations"]["genre_mapper"] and isinstance(lib["operations"]["genre_mapper"], dict):
params["genre_mapper"] = {}

@ -15,12 +15,14 @@ class Notifiarr:
self.apikey = params["apikey"]
self.develop = params["develop"]
self.test = params["test"]
logger.debug(f"Environment: {'Test' if self.test else 'Develop' if self.develop else 'Production'}")
url, _ = self.get_url("user/validate/")
response = self.config.get(url)
try:
response_json = response.json()
except JSONDecodeError as e:
raise Failed(e)
logger.debug(e)
raise Failed("Notifiarr Error: Invalid response")
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}")

@ -63,4 +63,4 @@ class PlaylistFile:
raise Failed(f"YAML Error: {util.tab_new_lines(ye)}")
except Exception as e:
util.print_stacktrace()
raise Failed(f"YAML Error: {e}")
raise Failed(f"YAML Error: {e}")

@ -846,7 +846,6 @@ def library_operations(config, library):
logger.info("")
util.separator(f"Starting TMDb Collections")
logger.info("")
suffixes = util.get_list(library.tmdb_collections["remove_suffix"])
new_collections = {}
for _i, _n in tmdb_collections.items():
if int(_i) not in library.tmdb_collections["exclude_ids"]:
@ -854,10 +853,9 @@ def library_operations(config, library):
for k, v in library.tmdb_collections["dictionary_variables"]:
if int(_i) in v:
template[k] = v[int(_i)]
if suffixes:
for suffix in suffixes:
if _n.endswith(suffix):
_n = _n[:-len(_n)]
for suffix in library.tmdb_collections["remove_suffix"]:
if _n.endswith(suffix):
_n = _n[:-len(_n)]
new_collections[_n.strip()] = {"template": template}
metadata = MetadataFile(config, library, "Data", {
"collections": new_collections,
@ -1044,7 +1042,7 @@ def run_collection(config, library, metadata, requested_collections):
logger.info("")
logger.info(f"Plex Server Movie pre-roll video updated to {builder.server_preroll}")
if (builder.item_details or builder.custom_sort or builder.sort_by) and run_item_details and builder.builders:
if (builder.item_details or builder.custom_sort) and run_item_details and builder.builders:
try:
builder.load_collection_items()
except Failed:
@ -1053,7 +1051,7 @@ def run_collection(config, library, metadata, requested_collections):
else:
if builder.item_details:
builder.update_item_details()
if builder.custom_sort or builder.sort_by:
if builder.custom_sort:
library.run_sort.append(builder)
# builder.sort_collection()

Loading…
Cancel
Save