added Collection Run Time

This commit is contained in:
meisnate12 2021-05-20 16:38:48 -04:00
parent 8519342eb3
commit 1758dad7ca
4 changed files with 13 additions and 25 deletions

View file

@ -1601,23 +1601,6 @@ class CollectionBuilder:
self.library.collection_order_query(self.obj, self.details["collection_order"])
logger.info(f"Detail: collection_order updated Collection Order to {self.details['collection_order']}")
if "label" in self.details or "label.remove" in self.details or "label.sync" in self.details:
item_labels = [label.tag for label in self.obj.labels]
if "label" in self.details or "label.sync" in self.details:
labels = self.details["label" if "label" in self.details else "label.sync"]
if "label.sync" in self.details:
for label in (la for la in item_labels if la not in labels):
self.library.query_data(self.obj.removeLabel, label)
logger.info(f"Detail: Label {label} removed")
for label in (la for la in labels if la not in item_labels):
self.library.query_data(self.obj.addLabel, label)
logger.info(f"Detail: Label {label} added")
if "label.remove" in self.details:
for label in self.details["label.remove"]:
if label in item_labels:
self.library.query_data(self.obj.removeLabel, label)
logger.info(f"Detail: Label {label} removed")
add_tags = self.details["label"] if "label" in self.details else None
remove_tags = self.details["label.remove"] if "label.remove" in self.details else None
sync_tags = self.details["label.sync"] if "label.sync" in self.details else None

View file

@ -324,7 +324,9 @@ class PlexAPI:
self.Sonarr = None
self.Tautulli = None
self.name = params["name"]
self.mapping_name = util.validate_filename(params["mapping_name"])
self.mapping_name, output = util.validate_filename(params["mapping_name"])
if output:
logger.info(output)
self.missing_path = os.path.join(params["default_dir"], f"{self.name}_missing.yml")
self.metadata_path = params["metadata_path"]
self.asset_directory = params["asset_directory"]

View file

@ -393,8 +393,7 @@ def print_end(length, text=None):
def validate_filename(filename):
if is_valid_filename(filename):
return filename
return filename, None
else:
mapping_name = sanitize_filename(filename)
logger.info(f"Folder Name: {filename} is invalid using {mapping_name}")
return mapping_name
return mapping_name, f"Log Folder Name: {filename} is invalid using {mapping_name}"

View file

@ -115,7 +115,7 @@ def start(config_path, is_test, daily, requested_collections, requested_librarie
logger.critical(e)
logger.info("")
util.separator(f"Finished {start_type}Run\nRun Time: {str(datetime.now() - start_time).split('.')[0]}")
logger.addHandler(file_handler)
logger.removeHandler(file_handler)
def update_libraries(config, is_test, requested_collections, resume_from):
for library in config.libraries:
@ -372,10 +372,10 @@ def mass_metadata(config, library, movie_map, show_map):
except Failed as e:
logger.error(e)
def run_collection(config, library, metadata, requested_collections, is_test, resume_from, movie_map, show_map):
logger.info("")
for mapping_name, collection_attrs in requested_collections.items():
collection_start = datetime.now()
if is_test and ("test" not in collection_attrs or collection_attrs["test"] is not True):
no_template_test = True
if "template" in collection_attrs and collection_attrs["template"]:
@ -399,9 +399,9 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
util.separator(f"Resuming Collections")
if "name_mapping" in collection_attrs and collection_attrs["name_mapping"]:
collection_log_name = util.validate_filename(collection_attrs["name_mapping"])
collection_log_name, output_str = util.validate_filename(collection_attrs["name_mapping"])
else:
collection_log_name = util.validate_filename(mapping_name)
collection_log_name, output_str = util.validate_filename(mapping_name)
collection_log_folder = os.path.join(default_dir, "logs", library.mapping_name, "collections", collection_log_name)
os.makedirs(collection_log_folder, exist_ok=True)
col_file_logger = os.path.join(collection_log_folder, f"collection.log")
@ -415,6 +415,9 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
try:
util.separator(f"{mapping_name} Collection")
logger.info("")
if output_str:
logger.info(output_str)
logger.info("")
builder = CollectionBuilder(config, library, metadata, mapping_name, collection_attrs)
@ -453,6 +456,7 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
util.print_stacktrace()
logger.error(f"Unknown Error: {e}")
logger.info("")
util.separator(f"Finished {mapping_name} Collection\nCollection Run Time: {str(datetime.now() - collection_start).split('.')[0]}")
logger.removeHandler(collection_handler)
return resume_from