mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-14 00:37:22 +00:00
added collection_minimum and delete_below_minimum
This commit is contained in:
parent
a232decd18
commit
5c1e40aeef
4 changed files with 25 additions and 4 deletions
|
@ -76,13 +76,13 @@ summary_details = [
|
||||||
]
|
]
|
||||||
poster_details = ["url_poster", "tmdb_poster", "tmdb_profile", "tvdb_poster", "file_poster"]
|
poster_details = ["url_poster", "tmdb_poster", "tmdb_profile", "tvdb_poster", "file_poster"]
|
||||||
background_details = ["url_background", "tmdb_background", "tvdb_background", "file_background"]
|
background_details = ["url_background", "tmdb_background", "tvdb_background", "file_background"]
|
||||||
boolean_details = ["visible_library", "visible_home", "visible_shared", "show_filtered", "show_missing", "save_missing", "item_assets", "missing_only_released", "revert_overlay"]
|
boolean_details = ["visible_library", "visible_home", "visible_shared", "show_filtered", "show_missing", "save_missing", "item_assets", "missing_only_released", "revert_overlay", "delete_below_minimum"]
|
||||||
string_details = ["sort_title", "content_rating", "name_mapping"]
|
string_details = ["sort_title", "content_rating", "name_mapping"]
|
||||||
ignored_details = [
|
ignored_details = [
|
||||||
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test",
|
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test",
|
||||||
"tmdb_person", "build_collection", "collection_order", "collection_level", "validate_builders", "collection_name"
|
"tmdb_person", "build_collection", "collection_order", "collection_level", "validate_builders", "collection_name"
|
||||||
]
|
]
|
||||||
details = ["collection_mode", "collection_order", "collection_level", "label"] + boolean_details + string_details
|
details = ["collection_mode", "collection_order", "collection_level", "collection_minimum", "label"] + boolean_details + string_details
|
||||||
collectionless_details = ["collection_order", "plex_collectionless", "label", "label_sync_mode", "test"] + \
|
collectionless_details = ["collection_order", "plex_collectionless", "label", "label_sync_mode", "test"] + \
|
||||||
poster_details + background_details + summary_details + string_details
|
poster_details + background_details + summary_details + string_details
|
||||||
item_details = ["item_label", "item_radarr_tag", "item_sonarr_tag", "item_overlay"] + list(plex.item_advance_keys.keys())
|
item_details = ["item_label", "item_radarr_tag", "item_sonarr_tag", "item_overlay"] + list(plex.item_advance_keys.keys())
|
||||||
|
@ -187,6 +187,8 @@ class CollectionBuilder:
|
||||||
self.backgrounds = {}
|
self.backgrounds = {}
|
||||||
self.summaries = {}
|
self.summaries = {}
|
||||||
self.schedule = ""
|
self.schedule = ""
|
||||||
|
self.minimum = self.library.collection_minimum
|
||||||
|
self.delete_below_minimum = self.library.delete_below_minimum
|
||||||
self.current_time = datetime.now()
|
self.current_time = datetime.now()
|
||||||
self.current_year = self.current_time.year
|
self.current_year = self.current_time.year
|
||||||
|
|
||||||
|
@ -679,6 +681,8 @@ class CollectionBuilder:
|
||||||
self.details[method_name] = plex.collection_mode_options[str(method_data).lower()]
|
self.details[method_name] = plex.collection_mode_options[str(method_data).lower()]
|
||||||
else:
|
else:
|
||||||
raise Failed(f"Collection Error: {method_data} collection_mode invalid\n\tdefault (Library default)\n\thide (Hide Collection)\n\thide_items (Hide Items in this Collection)\n\tshow_items (Show this Collection and its Items)")
|
raise Failed(f"Collection Error: {method_data} collection_mode invalid\n\tdefault (Library default)\n\thide (Hide Collection)\n\thide_items (Hide Items in this Collection)\n\tshow_items (Show this Collection and its Items)")
|
||||||
|
elif method_name == "collection_minimum":
|
||||||
|
self.minimum = util.parse(method_name, method_data, datatype="int", minimum=1)
|
||||||
elif method_name == "label":
|
elif method_name == "label":
|
||||||
if "label" in methods and "label.sync" in methods:
|
if "label" in methods and "label.sync" in methods:
|
||||||
raise Failed("Collection Error: Cannot use label and label.sync together")
|
raise Failed("Collection Error: Cannot use label and label.sync together")
|
||||||
|
@ -1815,6 +1819,10 @@ class CollectionBuilder:
|
||||||
os.remove(og_image)
|
os.remove(og_image)
|
||||||
self.config.Cache.update_image_map(item.ratingKey, self.library.image_table_name, "", "")
|
self.config.Cache.update_image_map(item.ratingKey, self.library.image_table_name, "", "")
|
||||||
|
|
||||||
|
def delete_collection(self):
|
||||||
|
if self.obj:
|
||||||
|
self.library.query(self.obj.delete)
|
||||||
|
|
||||||
def update_details(self):
|
def update_details(self):
|
||||||
if not self.obj and self.smart_url:
|
if not self.obj and self.smart_url:
|
||||||
self.library.create_smart_collection(self.name, self.smart_type_key, self.smart_url)
|
self.library.create_smart_collection(self.name, self.smart_type_key, self.smart_url)
|
||||||
|
|
|
@ -184,7 +184,9 @@ class Config:
|
||||||
"show_missing": check_for_attribute(self.data, "show_missing", parent="settings", var_type="bool", default=True),
|
"show_missing": check_for_attribute(self.data, "show_missing", parent="settings", var_type="bool", default=True),
|
||||||
"save_missing": check_for_attribute(self.data, "save_missing", parent="settings", var_type="bool", default=True),
|
"save_missing": check_for_attribute(self.data, "save_missing", parent="settings", var_type="bool", default=True),
|
||||||
"missing_only_released": check_for_attribute(self.data, "missing_only_released", parent="settings", var_type="bool", default=False),
|
"missing_only_released": check_for_attribute(self.data, "missing_only_released", parent="settings", var_type="bool", default=False),
|
||||||
"create_asset_folders": check_for_attribute(self.data, "create_asset_folders", parent="settings", var_type="bool", default=False)
|
"create_asset_folders": check_for_attribute(self.data, "create_asset_folders", parent="settings", var_type="bool", default=False),
|
||||||
|
"collection_minimum": check_for_attribute(self.data, "collection_minimum", parent="settings", var_type="int", default=1),
|
||||||
|
"delete_below_minimum": check_for_attribute(self.data, "delete_below_minimum", parent="settings", var_type="bool", default=False)
|
||||||
}
|
}
|
||||||
if self.general["cache"]:
|
if self.general["cache"]:
|
||||||
util.separator()
|
util.separator()
|
||||||
|
@ -353,6 +355,8 @@ class Config:
|
||||||
params["save_missing"] = check_for_attribute(lib, "save_missing", parent="settings", var_type="bool", default=self.general["save_missing"], do_print=False, save=False)
|
params["save_missing"] = check_for_attribute(lib, "save_missing", parent="settings", var_type="bool", default=self.general["save_missing"], do_print=False, save=False)
|
||||||
params["missing_only_released"] = check_for_attribute(lib, "missing_only_released", parent="settings", var_type="bool", default=self.general["missing_only_released"], do_print=False, save=False)
|
params["missing_only_released"] = check_for_attribute(lib, "missing_only_released", parent="settings", var_type="bool", default=self.general["missing_only_released"], do_print=False, save=False)
|
||||||
params["create_asset_folders"] = check_for_attribute(lib, "create_asset_folders", parent="settings", var_type="bool", default=self.general["create_asset_folders"], do_print=False, save=False)
|
params["create_asset_folders"] = check_for_attribute(lib, "create_asset_folders", parent="settings", var_type="bool", default=self.general["create_asset_folders"], do_print=False, save=False)
|
||||||
|
params["collection_minimum"] = check_for_attribute(lib, "collection_minimum", parent="settings", var_type="int", default=self.general["collection_minimum"], do_print=False, save=False)
|
||||||
|
params["delete_below_minimum"] = check_for_attribute(lib, "delete_below_minimum", parent="settings", var_type="bool", default=self.general["delete_below_minimum"], do_print=False, save=False)
|
||||||
|
|
||||||
params["mass_genre_update"] = check_for_attribute(lib, "mass_genre_update", test_list=mass_update_options, default_is_none=True, save=False, do_print=lib and "mass_genre_update" in lib)
|
params["mass_genre_update"] = check_for_attribute(lib, "mass_genre_update", test_list=mass_update_options, default_is_none=True, save=False, do_print=lib and "mass_genre_update" in lib)
|
||||||
if self.OMDb is None and params["mass_genre_update"] == "omdb":
|
if self.OMDb is None and params["mass_genre_update"] == "omdb":
|
||||||
|
|
|
@ -313,6 +313,8 @@ class Plex:
|
||||||
logger.info(output)
|
logger.info(output)
|
||||||
self.image_table_name = self.config.Cache.get_image_table_name(self.original_mapping_name) if self.config.Cache else None
|
self.image_table_name = self.config.Cache.get_image_table_name(self.original_mapping_name) if self.config.Cache else None
|
||||||
self.missing_path = os.path.join(params["default_dir"], f"{self.name}_missing.yml")
|
self.missing_path = os.path.join(params["default_dir"], f"{self.name}_missing.yml")
|
||||||
|
self.collection_minimum = params["collection_minimum"]
|
||||||
|
self.delete_below_minimum = params["delete_below_minimum"]
|
||||||
self.metadata_path = params["metadata_path"]
|
self.metadata_path = params["metadata_path"]
|
||||||
self.asset_directory = params["asset_directory"]
|
self.asset_directory = params["asset_directory"]
|
||||||
self.asset_folders = params["asset_folders"]
|
self.asset_folders = params["asset_folders"]
|
||||||
|
|
|
@ -497,11 +497,18 @@ def run_collection(config, library, metadata, requested_collections):
|
||||||
|
|
||||||
builder.find_rating_keys()
|
builder.find_rating_keys()
|
||||||
|
|
||||||
if len(builder.rating_keys) > 0 and builder.build_collection:
|
if len(builder.rating_keys) >= builder.minimum and builder.build_collection:
|
||||||
logger.info("")
|
logger.info("")
|
||||||
util.separator(f"Adding to {mapping_name} Collection", space=False, border=False)
|
util.separator(f"Adding to {mapping_name} Collection", space=False, border=False)
|
||||||
logger.info("")
|
logger.info("")
|
||||||
builder.add_to_collection()
|
builder.add_to_collection()
|
||||||
|
elif len(builder.rating_keys) < builder.minimum and builder.build_collection:
|
||||||
|
logger.info("")
|
||||||
|
logger.info(f"Collection minimum: {builder.minimum} not met for {mapping_name} Collection")
|
||||||
|
logger.info("")
|
||||||
|
if library.delete_below_minimum and builder.obj:
|
||||||
|
builder.delete_collection()
|
||||||
|
logger.info(f"Collection {builder.obj.title} deleted")
|
||||||
if builder.do_missing and (len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0):
|
if builder.do_missing and (len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0):
|
||||||
if builder.details["show_missing"] is True:
|
if builder.details["show_missing"] is True:
|
||||||
logger.info("")
|
logger.info("")
|
||||||
|
|
Loading…
Reference in a new issue