[73] add collection/playlist names to end hook

This commit is contained in:
meisnate12 2022-02-19 19:08:41 -05:00
parent e3007b4461
commit a78b0737f5
5 changed files with 10 additions and 6 deletions

View file

@ -1 +1 @@
1.15.1-develop72
1.15.1-develop73

View file

@ -89,7 +89,7 @@ class Library(ABC):
self.clean_bundles = params["plex"]["clean_bundles"] # TODO: Here or just in Plex?
self.empty_trash = params["plex"]["empty_trash"] # TODO: Here or just in Plex?
self.optimize = params["plex"]["optimize"] # TODO: Here or just in Plex?
self.stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0}
self.stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []}
self.status = {}
self.items_library_operation = True if self.assets_for_all or self.mass_genre_update or self.mass_audience_rating_update \

View file

@ -58,7 +58,6 @@ class MyLogger:
def _get_handler(self, log_file, count=3):
_handler = RotatingFileHandler(log_file, delay=True, mode="w", backupCount=count, encoding="utf-8")
self._formatter(_handler)
_handler.addFilter(fmt_filter)
if os.path.isfile(log_file):
_handler.doRollover()
return _handler
@ -71,6 +70,7 @@ class MyLogger:
def add_main_handler(self):
self.main_handler = self._get_handler(self.main_log, count=10)
self.main_handler.addFilter(fmt_filter)
self._logger.addHandler(self.main_handler)
def remove_main_handler(self):

View file

@ -61,6 +61,7 @@ class Webhooks:
"items_removed": stats["removed"],
"added_to_radarr": stats["radarr"],
"added_to_sonarr": stats["sonarr"],
"names": stats["names"]
})
def error_hooks(self, text, server=None, library=None, collection=None, playlist=None, critical=True):

View file

@ -372,7 +372,7 @@ def update_libraries(config):
if playlist_status:
print_status("Playlists", playlist_status)
stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0}
stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []}
stats["added"] += amount_added
for library in config.libraries:
stats["created"] += library.stats["created"]
@ -383,6 +383,7 @@ def update_libraries(config):
stats["removed"] += library.stats["removed"]
stats["radarr"] += library.stats["radarr"]
stats["sonarr"] += library.stats["sonarr"]
stats["names"].extend([{"name": n, "library": library.name} for n in library.stats["names"]])
if playlist_stats:
stats["created"] += playlist_stats["created"]
stats["modified"] += playlist_stats["modified"]
@ -392,7 +393,7 @@ def update_libraries(config):
stats["removed"] += playlist_stats["removed"]
stats["radarr"] += playlist_stats["radarr"]
stats["sonarr"] += playlist_stats["sonarr"]
stats["names"].extend([{"name": n, "library": "PLAYLIST"} for n in playlist_stats["names"]])
return stats
def library_operations(config, library):
@ -807,6 +808,7 @@ def run_collection(config, library, metadata, requested_collections):
logger.separator(f"Validating {mapping_name} Attributes", space=False, border=False)
builder = CollectionBuilder(config, metadata, mapping_name, no_missing, collection_attrs, library=library)
library.stats["names"].append(builder.name)
logger.info("")
logger.separator(f"Running {mapping_name} Collection", space=False, border=False)
@ -938,7 +940,7 @@ def run_collection(config, library, metadata, requested_collections):
logger.remove_collection_handler(library.mapping_name, collection_log_name)
def run_playlists(config):
stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0}
stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0, "names": []}
status = {}
logger.info("")
logger.separator("Playlists")
@ -979,6 +981,7 @@ def run_playlists(config):
logger.separator(f"Validating {mapping_name} Attributes", space=False, border=False)
builder = CollectionBuilder(config, playlist_file, mapping_name, no_missing, playlist_attrs)
stats["names"].append(builder.name)
logger.info("")
logger.separator(f"Running {mapping_name} Playlist", space=False, border=False)