[65] #738 Even more expanded summary

pull/858/head
meisnate12 3 years ago
parent 07471b06a8
commit 54c7581bf8

@ -1 +1 @@
1.16.5-develop64 1.16.5-develop65

@ -1,4 +1,5 @@
import os, re import os, re
from datetime import datetime
from modules import plex, util from modules import plex, util
from modules.util import Failed from modules.util import Failed
from plexapi.audio import Artist from plexapi.audio import Artist
@ -13,6 +14,7 @@ class Operations:
self.library = library self.library = library
def run_operations(self): def run_operations(self):
operation_start = datetime.now()
logger.info("") logger.info("")
logger.separator(f"{self.library.name} Library Operations") logger.separator(f"{self.library.name} Library Operations")
logger.info("") logger.info("")
@ -499,3 +501,8 @@ class Operations:
logger.info(f"{len(meta['metadata'])} {self.library.type.capitalize()}{'s' if len(meta['metadata']) > 1 else ''} Backed Up") logger.info(f"{len(meta['metadata'])} {self.library.type.capitalize()}{'s' if len(meta['metadata']) > 1 else ''} Backed Up")
except yaml.scanner.ScannerError as e: except yaml.scanner.ScannerError as e:
logger.error(f"YAML Error: {util.tab_new_lines(e)}") logger.error(f"YAML Error: {util.tab_new_lines(e)}")
operation_run_time = str(datetime.now() - operation_start).split('.')[0]
logger.info("")
logger.separator(f"Finished {self.library.name} Library Operations\nOperations Run Time: {operation_run_time}")
return operation_run_time

@ -1,4 +1,5 @@
import os, re, time import os, re, time
from datetime import datetime
from modules import util from modules import util
from modules.builder import CollectionBuilder from modules.builder import CollectionBuilder
from modules.util import Failed from modules.util import Failed
@ -16,6 +17,7 @@ class Overlays:
self.overlays = [] self.overlays = []
def run_overlays(self): def run_overlays(self):
overlay_start = datetime.now()
logger.info("") logger.info("")
logger.separator(f"{self.library.name} Library Overlays") logger.separator(f"{self.library.name} Library Overlays")
logger.info("") logger.info("")
@ -169,6 +171,10 @@ class Overlays:
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
logger.exorcise() logger.exorcise()
overlay_run_time = str(datetime.now() - overlay_start).split('.')[0]
logger.info("")
logger.separator(f"Finished {self.library.name} Library Overlays\nOverlays Run Time: {overlay_run_time}")
return overlay_run_time
def get_item_sort_title(self, item_to_sort, atr="titleSort"): def get_item_sort_title(self, item_to_sort, atr="titleSort"):
if isinstance(item_to_sort, Album): if isinstance(item_to_sort, Album):
@ -318,4 +324,4 @@ class Overlays:
if original: if original:
os.remove(original) os.remove(original)
else: else:
logger.error(f"No Poster found to restore for {item_title}") logger.error(f"No Poster found to restore for {item_title}")

@ -226,11 +226,13 @@ def start(attrs):
logger.remove_main_handler() logger.remove_main_handler()
def update_libraries(config): def update_libraries(config):
library_status = {}
for library in config.libraries: for library in config.libraries:
if library.skip_library: if library.skip_library:
logger.info("") logger.info("")
logger.separator(f"Skipping {library.name} Library") logger.separator(f"Skipping {library.name} Library")
continue continue
library_status[library.name] = {}
try: try:
logger.add_library_handler(library.mapping_name) logger.add_library_handler(library.mapping_name)
plexapi.server.TIMEOUT = library.timeout plexapi.server.TIMEOUT = library.timeout
@ -264,27 +266,32 @@ def update_libraries(config):
logger.debug(f"Timeout: {library.timeout}") logger.debug(f"Timeout: {library.timeout}")
if config.delete_collections: if config.delete_collections:
time_start = datetime.now()
logger.info("") logger.info("")
logger.separator(f"Deleting all Collections from the {library.name} Library", space=False, border=False) logger.separator(f"Deleting all Collections from the {library.name} Library", space=False, border=False)
logger.info("") logger.info("")
for collection in library.get_all_collections(): for collection in library.get_all_collections():
logger.info(f"Collection {collection.title} Deleted") logger.info(f"Collection {collection.title} Deleted")
library.query(collection.delete) library.query(collection.delete)
library_status[library.name]["All Collections Deleted"] = str(datetime.now() - time_start).split('.')[0]
temp_items = library.cache_items() temp_items = library.cache_items()
if not library.is_other and not library.is_music: if not library.is_other and not library.is_music:
time_start = datetime.now()
logger.info("") logger.info("")
logger.separator(f"Mapping {library.name} Library", space=False, border=False) logger.separator(f"Mapping {library.name} Library", space=False, border=False)
logger.info("") logger.info("")
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]
if config.library_first and not config.test_mode and not collection_only: if config.library_first and not config.test_mode and not collection_only:
if not overlays_only and library.library_operation: if not overlays_only and library.library_operation:
library.Operations.run_operations() library_status[library.name]["Library Operations"] = library.Operations.run_operations()
if not operations_only and (library.overlay_files or library.remove_overlays): if not operations_only and (library.overlay_files or library.remove_overlays):
library.Overlays.run_overlays() library_status[library.name]["Library Overlays"] = library.Overlays.run_overlays()
if not operations_only and not overlays_only: if not operations_only and not overlays_only:
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:
@ -310,12 +317,13 @@ def update_libraries(config):
logger.remove_library_handler(library.mapping_name) logger.remove_library_handler(library.mapping_name)
run_collection(config, library, metadata, collections_to_run) run_collection(config, library, metadata, collections_to_run)
logger.re_add_library_handler(library.mapping_name) logger.re_add_library_handler(library.mapping_name)
library_status[library.name]["Library Metadata Files"] = str(datetime.now() - time_start).split('.')[0]
if not config.library_first and not config.test_mode and not collection_only: if not config.library_first and not config.test_mode and not collection_only:
if not overlays_only and library.library_operation: if not overlays_only and library.library_operation:
library.Operations.run_operations() library_status[library.name]["Library Operations"] = library.Operations.run_operations()
if not operations_only and (library.overlay_files or library.remove_overlays): if not operations_only and (library.overlay_files or library.remove_overlays):
library.Overlays.run_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:
@ -392,10 +400,7 @@ def update_libraries(config):
if len(title) > longest: if len(title) > longest:
longest = len(title) longest = len(title)
def print_status(section, status): def print_status( status):
logger.info("")
logger.separator(f"{section} Summary", space=False, border=False)
logger.info("")
logger.info(f"{'Title':^{longest}} | + | = | - | Run Time | {'Status'}") logger.info(f"{'Title':^{longest}} | + | = | - | Run Time | {'Status'}")
breaker = f"{logger.separating_character * longest}|{logger.separating_character * 5}|{logger.separating_character * 5}|{logger.separating_character * 5}|" breaker = f"{logger.separating_character * longest}|{logger.separating_character * 5}|{logger.separating_character * 5}|{logger.separating_character * 5}|"
logger.separator(breaker, space=False, border=False, side_space=False, left=True) logger.separator(breaker, space=False, border=False, side_space=False, left=True)
@ -408,9 +413,19 @@ def update_libraries(config):
logger.separator("Summary") logger.separator("Summary")
for library in config.libraries: for library in config.libraries:
print_status(library.name, library.status) logger.info("")
logger.separator(f"{library.name} Summary", space=False, border=False)
logger.info("")
logger.info(f"{'Title':<27} | Run Time")
for text, value in library_status[library.name].items():
logger.info(f"{text:<27} | {value:>8}")
logger.info("")
print_status(library.status)
if playlist_status: if playlist_status:
print_status("Playlists", playlist_status) logger.info("")
logger.separator(f"Playlists Summary", space=False, border=False)
logger.info("")
print_status(playlist_status)
stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []} stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []}
stats["added"] += amount_added stats["added"] += amount_added

Loading…
Cancel
Save