From a3c4a3ebb7b30af1859fe7e2c88c9048df78e7d3 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Mon, 24 Jan 2022 10:57:48 -0500 Subject: [PATCH] #582 add --run-metadata to run specific metadata files --- modules/config.py | 1 + modules/meta.py | 9 +++++++++ plex_meta_manager.py | 11 +++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/config.py b/modules/config.py index 57d68d7e..ea841cec 100644 --- a/modules/config.py +++ b/modules/config.py @@ -54,6 +54,7 @@ class ConfigFile: self.run_hour = datetime.strptime(attrs["time"], "%H:%M").hour self.requested_collections = util.get_list(attrs["collections"]) if "collections" in attrs else None self.requested_libraries = util.get_list(attrs["libraries"]) if "libraries" in attrs else None + self.requested_metadata = util.get_list(attrs["metadata"]) if "metadata" in attrs else None self.resume_from = attrs["resume"] if "resume" in attrs else None yaml.YAML().allow_duplicate_keys = True diff --git a/modules/meta.py b/modules/meta.py index 71977ce1..5ad4a660 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -54,6 +54,15 @@ class DataFile: self.data_type = "" self.templates = {} + def get_file_name(self): + data = f"{github_base}{self.path}.yml" if self.type == "GIT" else self.path + if "/" in data: + return data[data.rfind("/") + 1:-4] + elif "\\" in data: + return data[data.rfind("\\") + 1:-4] + else: + return data + def load_file(self): try: if self.type in ["URL", "Git"]: diff --git a/plex_meta_manager.py b/plex_meta_manager.py index f6541661..62c8f023 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -34,6 +34,7 @@ parser.add_argument("-lo", "--library-only", "--libraries-only", dest="library_o parser.add_argument("-lf", "--library-first", "--libraries-first", dest="library_first", help="Run library operations before collections", 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("-rm", "-m", "--metadata", "--metadatas", "--run-metadata", "--run-metadatas", dest="metadata", help="Process only specified Metadata files (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) @@ -69,6 +70,7 @@ library_only = get_arg("PMM_LIBRARIES_ONLY", args.library_only, arg_bool=True) library_first = get_arg("PMM_LIBRARIES_FIRST", args.library_first, arg_bool=True) collections = get_arg("PMM_COLLECTIONS", args.collections) libraries = get_arg("PMM_LIBRARIES", args.libraries) +metadatas = get_arg("PMM_METADATA", args.metadata) 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) @@ -158,6 +160,7 @@ def start(attrs): logger.debug(f"--libraries-first (PMM_LIBRARIES_FIRST): {library_first}") logger.debug(f"--run-collections (PMM_COLLECTIONS): {collections}") logger.debug(f"--run-libraries (PMM_LIBRARIES): {libraries}") + logger.debug(f"--run-metadata (PMM_METADATA): {metadatas}") logger.debug(f"--ignore-schedules (PMM_IGNORE_SCHEDULES): {ignore_schedules}") logger.debug(f"--delete-collections (PMM_DELETE_COLLECTIONS): {delete}") logger.debug(f"--resume (PMM_RESUME): {resume}") @@ -258,8 +261,11 @@ def update_libraries(config): logger.info("") library.map_guids() for metadata in library.metadata_files: + metadata_name = metadata.get_file_name() + if config.requested_metadata and metadata_name not in config.requested_metadata: + continue logger.info("") - util.separator(f"Running Metadata File\n{metadata.path}") + util.separator(f"Running {metadata_name} Metadata File\n{metadata.path}") if not config.test_mode and not config.resume_from and not collection_only: try: metadata.update_metadata() @@ -1208,7 +1214,7 @@ def run_playlists(config): return status, stats try: - if run or test or collections or libraries or resume: + if run or test or collections or libraries or metadatas or resume: start({ "config_file": config_file, "test": test, @@ -1216,6 +1222,7 @@ try: "ignore_schedules": ignore_schedules, "collections": collections, "libraries": libraries, + "metadata": metadatas, "library_first": library_first, "resume": resume, "trace": trace