mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[35] fix run_order
This commit is contained in:
parent
4e7c396717
commit
4693e6505e
3 changed files with 53 additions and 57 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.19.1-develop34
|
1.19.1-develop35
|
||||||
|
|
|
@ -158,7 +158,6 @@ class ConfigFile:
|
||||||
self.collection_only = attrs["collection_only"] if "collection_only" in attrs else False
|
self.collection_only = attrs["collection_only"] if "collection_only" in attrs else False
|
||||||
self.operations_only = attrs["operations_only"] if "operations_only" in attrs else False
|
self.operations_only = attrs["operations_only"] if "operations_only" in attrs else False
|
||||||
self.overlays_only = attrs["overlays_only"] if "overlays_only" in attrs else False
|
self.overlays_only = attrs["overlays_only"] if "overlays_only" in attrs else False
|
||||||
self.libraries_first = attrs["libraries_first"] if "libraries_first" in attrs else False
|
|
||||||
self.env_plex_url = attrs["plex_url"] if "plex_url" in attrs else ""
|
self.env_plex_url = attrs["plex_url"] if "plex_url" in attrs else ""
|
||||||
self.env_plex_token = attrs["plex_token"] if "plex_token" in attrs else ""
|
self.env_plex_token = attrs["plex_token"] if "plex_token" in attrs else ""
|
||||||
current_time = datetime.now()
|
current_time = datetime.now()
|
||||||
|
@ -400,10 +399,8 @@ class ConfigFile:
|
||||||
logger.warning(options)
|
logger.warning(options)
|
||||||
return default
|
return default
|
||||||
|
|
||||||
default_run = ["overlays", "operations", "metadata"] if self.libraries_first else ["metadata", "overlays", "operations"]
|
|
||||||
|
|
||||||
self.general = {
|
self.general = {
|
||||||
"run_order": check_for_attribute(self.data, "run_order", parent="settings", var_type="comma_list", test_list=run_order_options, default=default_run),
|
"run_order": check_for_attribute(self.data, "run_order", parent="settings", var_type="comma_list", test_list=run_order_options, default=["operations", "metadata", "overlays"]),
|
||||||
"cache": check_for_attribute(self.data, "cache", parent="settings", var_type="bool", default=True),
|
"cache": check_for_attribute(self.data, "cache", parent="settings", var_type="bool", default=True),
|
||||||
"cache_expiration": check_for_attribute(self.data, "cache_expiration", parent="settings", var_type="int", default=60, int_min=1),
|
"cache_expiration": check_for_attribute(self.data, "cache_expiration", parent="settings", var_type="int", default=60, int_min=1),
|
||||||
"asset_directory": check_for_attribute(self.data, "asset_directory", parent="settings", var_type="list_path", default_is_none=True),
|
"asset_directory": check_for_attribute(self.data, "asset_directory", parent="settings", var_type="list_path", default_is_none=True),
|
||||||
|
|
|
@ -38,7 +38,6 @@ arguments = {
|
||||||
"run-collections": {"args": ["rc", "cl", "collection", "collections", "run-collection"], "type": "str", "help": "Process only specified collections (pipe-separated list '|')"},
|
"run-collections": {"args": ["rc", "cl", "collection", "collections", "run-collection"], "type": "str", "help": "Process only specified collections (pipe-separated list '|')"},
|
||||||
"run-libraries": {"args": ["rl", "l", "library", "libraries", "run-library"], "type": "str", "help": "Process only specified libraries (pipe-separated list '|')"},
|
"run-libraries": {"args": ["rl", "l", "library", "libraries", "run-library"], "type": "str", "help": "Process only specified libraries (pipe-separated list '|')"},
|
||||||
"run-metadata-files": {"args": ["rm", "m", "metadata", "metadata-files"], "type": "str", "help": "Process only specified Metadata files (pipe-separated list '|')"},
|
"run-metadata-files": {"args": ["rm", "m", "metadata", "metadata-files"], "type": "str", "help": "Process only specified Metadata files (pipe-separated list '|')"},
|
||||||
"libraries-first": {"args": ["lf", "library-first"], "type": "bool", "help": argparse.SUPPRESS},
|
|
||||||
"ignore-schedules": {"args": "is", "type": "bool", "help": "Run ignoring collection schedules"},
|
"ignore-schedules": {"args": "is", "type": "bool", "help": "Run ignoring collection schedules"},
|
||||||
"ignore-ghost": {"args": "ig", "type": "bool", "help": "Run ignoring ghost logging"},
|
"ignore-ghost": {"args": "ig", "type": "bool", "help": "Run ignoring ghost logging"},
|
||||||
"delete-collections": {"args": ["dc", "delete", "delete-collection"], "type": "bool", "help": "Deletes all Collections in the Plex Library before running"},
|
"delete-collections": {"args": ["dc", "delete", "delete-collection"], "type": "bool", "help": "Deletes all Collections in the Plex Library before running"},
|
||||||
|
@ -269,7 +268,6 @@ def start(attrs):
|
||||||
attrs["playlist_only"] = run_args["playlists-only"]
|
attrs["playlist_only"] = run_args["playlists-only"]
|
||||||
attrs["operations_only"] = run_args["operations-only"]
|
attrs["operations_only"] = run_args["operations-only"]
|
||||||
attrs["overlays_only"] = run_args["overlays-only"]
|
attrs["overlays_only"] = run_args["overlays-only"]
|
||||||
attrs["libraries_first"] = run_args["libraries-first"]
|
|
||||||
attrs["plex_url"] = plex_url
|
attrs["plex_url"] = plex_url
|
||||||
attrs["plex_token"] = plex_token
|
attrs["plex_token"] = plex_token
|
||||||
logger.separator(debug=True)
|
logger.separator(debug=True)
|
||||||
|
@ -578,60 +576,61 @@ def run_libraries(config):
|
||||||
library.map_guids(temp_items)
|
library.map_guids(temp_items)
|
||||||
library_status[library.name]["Library Loading and Mapping"] = str(datetime.now() - time_start).split('.')[0]
|
library_status[library.name]["Library Loading and Mapping"] = str(datetime.now() - time_start).split('.')[0]
|
||||||
|
|
||||||
|
runs = {
|
||||||
|
"metadata": all([not run_args[x] for x in ["operations-only", "overlays-only", "playlists-only"]]),
|
||||||
|
"operations": all([not run_args[x] for x in ["tests", "collections-only", "overlays-only", "playlists-only"]]),
|
||||||
|
"overlays": all([not run_args[x] for x in ["tests", "collections-only", "operations-only", "playlists-only"]]),
|
||||||
|
}
|
||||||
for run_type in library.run_order:
|
for run_type in library.run_order:
|
||||||
if run_type == "metadata":
|
if run_type == "metadata" and runs[run_type]:
|
||||||
if not run_args["operations-only"] and not run_args["overlays-only"] and not run_args["playlists-only"]:
|
time_start = datetime.now()
|
||||||
time_start = datetime.now()
|
for images in library.images_files:
|
||||||
for images in library.images_files:
|
images_name = images.get_file_name()
|
||||||
images_name = images.get_file_name()
|
if config.requested_metadata_files and images_name not in config.requested_metadata_files:
|
||||||
if config.requested_metadata_files and images_name not in config.requested_metadata_files:
|
|
||||||
logger.info("")
|
|
||||||
logger.separator(f"Skipping {images_name} Images File")
|
|
||||||
continue
|
|
||||||
logger.info("")
|
logger.info("")
|
||||||
logger.separator(f"Running {images_name} Images File\n{images.path}")
|
logger.separator(f"Skipping {images_name} Images File")
|
||||||
if not run_args["tests"] and not run_args["resume"] and not run_args["collections-only"]:
|
continue
|
||||||
try:
|
logger.info("")
|
||||||
images.update_metadata()
|
logger.separator(f"Running {images_name} Images File\n{images.path}")
|
||||||
except Failed as e:
|
if not run_args["tests"] and not run_args["resume"] and not run_args["collections-only"]:
|
||||||
library.notify(e)
|
try:
|
||||||
logger.error(e)
|
images.update_metadata()
|
||||||
library_status[library.name]["Library Images Files"] = str(datetime.now() - time_start).split('.')[0]
|
except Failed as e:
|
||||||
|
library.notify(e)
|
||||||
|
logger.error(e)
|
||||||
|
library_status[library.name]["Library Images Files"] = str(datetime.now() - time_start).split('.')[0]
|
||||||
|
|
||||||
time_start = datetime.now()
|
time_start = datetime.now()
|
||||||
for metadata in library.metadata_files:
|
for metadata in library.metadata_files:
|
||||||
metadata_name = metadata.get_file_name()
|
metadata_name = metadata.get_file_name()
|
||||||
if config.requested_metadata_files and metadata_name not in config.requested_metadata_files:
|
if config.requested_metadata_files and metadata_name not in config.requested_metadata_files:
|
||||||
logger.info("")
|
|
||||||
logger.separator(f"Skipping {metadata_name} Metadata File")
|
|
||||||
continue
|
|
||||||
logger.info("")
|
logger.info("")
|
||||||
logger.separator(f"Running {metadata_name} Metadata File\n{metadata.path}")
|
logger.separator(f"Skipping {metadata_name} Metadata File")
|
||||||
if not run_args["tests"] and not run_args["resume"] and not run_args["collections-only"]:
|
continue
|
||||||
try:
|
logger.info("")
|
||||||
metadata.update_metadata()
|
logger.separator(f"Running {metadata_name} Metadata File\n{metadata.path}")
|
||||||
except Failed as e:
|
if not run_args["tests"] and not run_args["resume"] and not run_args["collections-only"]:
|
||||||
library.notify(e)
|
try:
|
||||||
logger.error(e)
|
metadata.update_metadata()
|
||||||
collections_to_run = metadata.get_collections(config.requested_collections)
|
except Failed as e:
|
||||||
if run_args["resume"] and run_args["resume"] not in collections_to_run:
|
library.notify(e)
|
||||||
logger.info("")
|
logger.error(e)
|
||||||
logger.warning(f"Collection: {run_args['resume']} not in Metadata File: {metadata.path}")
|
collections_to_run = metadata.get_collections(config.requested_collections)
|
||||||
continue
|
if run_args["resume"] and run_args["resume"] not in collections_to_run:
|
||||||
if collections_to_run:
|
logger.info("")
|
||||||
logger.info("")
|
logger.warning(f"Collection: {run_args['resume']} not in Metadata File: {metadata.path}")
|
||||||
logger.separator(f"{'Test ' if run_args['tests'] else ''}Collections")
|
continue
|
||||||
# logger.remove_library_handler(library.mapping_name)
|
if collections_to_run:
|
||||||
run_collection(config, library, metadata, collections_to_run)
|
logger.info("")
|
||||||
# logger.re_add_library_handler(library.mapping_name)
|
logger.separator(f"{'Test ' if run_args['tests'] else ''}Collections")
|
||||||
library_status[library.name]["Library Metadata Files"] = str(datetime.now() - time_start).split('.')[0]
|
# logger.remove_library_handler(library.mapping_name)
|
||||||
elif run_type == "overlays":
|
run_collection(config, library, metadata, collections_to_run)
|
||||||
if not run_args["tests"] and not run_args["collections-only"] and not run_args["playlists-only"] and not config.requested_metadata_files and not run_args["overlays-only"] and library.library_operation:
|
# logger.re_add_library_handler(library.mapping_name)
|
||||||
library_status[library.name]["Library Operations"] = library.Operations.run_operations()
|
library_status[library.name]["Library Metadata Files"] = str(datetime.now() - time_start).split('.')[0]
|
||||||
elif run_type == "operations":
|
elif run_type == "operations" and runs[run_type] and not config.requested_metadata_files and library.library_operation:
|
||||||
if not run_args["tests"] and not run_args["collections-only"] and not run_args["playlists-only"] and not config.requested_metadata_files and not run_args["operations-only"] and (library.overlay_files or library.remove_overlays):
|
library_status[library.name]["Library Operations"] = library.Operations.run_operations()
|
||||||
library_status[library.name]["Library Overlays"] = library.Overlays.run_overlays()
|
elif run_type == "overlays" and runs[run_type] and not config.requested_metadata_files and (library.overlay_files or library.remove_overlays):
|
||||||
|
library_status[library.name]["Library Overlays"] = library.Overlays.run_overlays()
|
||||||
#logger.remove_library_handler(library.mapping_name)
|
#logger.remove_library_handler(library.mapping_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
library.notify(e)
|
library.notify(e)
|
||||||
|
|
Loading…
Reference in a new issue