mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 04:23:08 +00:00
add --delete-collections
This commit is contained in:
parent
f2ddb6fd46
commit
5b343932d6
4 changed files with 16 additions and 5 deletions
|
@ -46,6 +46,7 @@ class ConfigFile:
|
|||
self.read_only = read_only
|
||||
self.test_mode = attrs["test"] if "test" in attrs else False
|
||||
self.trace_mode = attrs["trace"] if "trace" in attrs else False
|
||||
self.delete_collections = attrs["delete"] if "delete" in attrs else False
|
||||
self.start_time = attrs["time_obj"]
|
||||
self.run_hour = datetime.strptime(attrs["time"], "%H:%M").hour
|
||||
self.requested_collections = util.get_list(attrs["collections"]) if "collections" in attrs else None
|
||||
|
@ -619,7 +620,6 @@ class ConfigFile:
|
|||
"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", 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):
|
||||
|
|
|
@ -469,7 +469,7 @@ class MetadataFile(DataFile):
|
|||
logger.info(f"Updating season {season_id} of {mapping_name}...")
|
||||
try:
|
||||
if isinstance(season_id, int):
|
||||
season = item.season(seasson=season_id)
|
||||
season = item.season(season=season_id)
|
||||
else:
|
||||
season = item.season(title=season_id)
|
||||
except NotFound:
|
||||
|
|
|
@ -925,7 +925,7 @@ class Plex(Library):
|
|||
os.makedirs(os.path.join(self.asset_directory[0], name), exist_ok=True)
|
||||
logger.info(f"Asset Directory Created: {os.path.join(self.asset_directory[0], name)}")
|
||||
elif isinstance(item, (Movie, Show)) and not overlay and folders and not found_folder:
|
||||
logger.error(f"Asset Warning: No asset folder found called '{name}'")
|
||||
logger.warning(f"Asset Warning: No asset folder found called '{name}'")
|
||||
elif isinstance(item, (Movie, Show)) and not poster and not background and self.show_missing_assets:
|
||||
logger.error(f"Asset Warning: No poster or background found in an assets folder for '{name}'")
|
||||
logger.warning(f"Asset Warning: No poster or background found in an assets folder for '{name}'")
|
||||
return None, None
|
||||
|
|
|
@ -32,6 +32,7 @@ parser.add_argument("-co", "--collection-only", "--collections-only", dest="coll
|
|||
parser.add_argument("-lo", "--library-only", "--libraries-only", dest="library_only", help="Run only library operations", action="store_true", default=False)
|
||||
parser.add_argument("-rc", "-cl", "--collection", "--collections", "--run-collection", "--run-collections", dest="collections", help="Process only specified collections (comma-separated list)", type=str)
|
||||
parser.add_argument("-rl", "-l", "--library", "--libraries", "--run-library", "--run-libraries", dest="libraries", help="Process only specified libraries (comma-separated list)", type=str)
|
||||
parser.add_argument("-dc", "--delete", "--delete-collections", dest="delete", help="Deletes all Collections in the Plex Library before running", action="store_true", default=False)
|
||||
parser.add_argument("-nc", "--no-countdown", dest="no_countdown", help="Run without displaying the countdown", action="store_true", default=False)
|
||||
parser.add_argument("-nm", "--no-missing", dest="no_missing", help="Run without running the missing section", action="store_true", default=False)
|
||||
parser.add_argument("-ro", "--read-only-config", dest="read_only_config", help="Run without writing to the config", action="store_true", default=False)
|
||||
|
@ -64,6 +65,7 @@ collection_only = get_arg("PMM_COLLECTIONS_ONLY", args.collection_only, arg_bool
|
|||
library_only = get_arg("PMM_LIBRARIES_ONLY", args.library_only, arg_bool=True)
|
||||
collections = get_arg("PMM_COLLECTIONS", args.collections)
|
||||
libraries = get_arg("PMM_LIBRARIES", args.libraries)
|
||||
delete = get_arg("PMM_DELETE_COLLECTIONS", args.delete, arg_bool=True)
|
||||
resume = get_arg("PMM_RESUME", args.resume)
|
||||
no_countdown = get_arg("PMM_NO_COUNTDOWN", args.no_countdown, arg_bool=True)
|
||||
no_missing = get_arg("PMM_NO_MISSING", args.no_missing, arg_bool=True)
|
||||
|
@ -151,6 +153,7 @@ def start(attrs):
|
|||
logger.debug(f"--libraries-only (PMM_LIBRARIES_ONLY): {library_only}")
|
||||
logger.debug(f"--run-collections (PMM_COLLECTIONS): {collections}")
|
||||
logger.debug(f"--run-libraries (PMM_LIBRARIES): {libraries}")
|
||||
logger.debug(f"--delete-collections (PMM_DELETE_COLLECTIONS): {delete}")
|
||||
logger.debug(f"--resume (PMM_RESUME): {resume}")
|
||||
logger.debug(f"--no-countdown (PMM_NO_COUNTDOWN): {no_countdown}")
|
||||
logger.debug(f"--no-missing (PMM_NO_MISSING): {no_missing}")
|
||||
|
@ -231,6 +234,13 @@ def update_libraries(config):
|
|||
logger.debug(f"Optimize: {library.optimize}")
|
||||
logger.debug(f"Timeout: {library.timeout}")
|
||||
|
||||
if config.delete_collections:
|
||||
logger.info("")
|
||||
util.separator(f"Deleting all Collections from the {library.name} Library", space=False, border=False)
|
||||
logger.info("")
|
||||
for collection in library.get_all_collections():
|
||||
logger.info(f"Collection {collection.title} Deleted")
|
||||
library.query(collection.delete)
|
||||
if not library.is_other and not library.is_music:
|
||||
logger.info("")
|
||||
util.separator(f"Mapping {library.name} Library", space=False, border=False)
|
||||
|
@ -1171,6 +1181,7 @@ try:
|
|||
start({
|
||||
"config_file": config_file,
|
||||
"test": test,
|
||||
"delete": delete,
|
||||
"collections": collections,
|
||||
"libraries": libraries,
|
||||
"resume": resume,
|
||||
|
@ -1188,7 +1199,7 @@ try:
|
|||
else:
|
||||
raise Failed(f"Argument Error: blank time argument")
|
||||
for time_to_run in valid_times:
|
||||
schedule.every().day.at(time_to_run).do(start, {"config_file": config_file, "time": time_to_run, "trace": trace})
|
||||
schedule.every().day.at(time_to_run).do(start, {"config_file": config_file, "time": time_to_run, "delete": delete, "trace": trace})
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
if not no_countdown:
|
||||
|
|
Loading…
Reference in a new issue