Minimize printed result
This is done by removing empty values that have no value when printed
MODIFY
plex_trakt_sync/trakt_api.py
plex_trakt_sync/trakt_api.py
@@ -236,6 +236,7 @@ def submit_collection(self):
try:
result = trakt.sync.add_to_collection(self.collection)
+ result = self.remove_empty_values(result)
if result:
logger.info(f"Updated Trakt collection: {result}")
finally:
@@ -249,3 +250,27 @@ def add_to_collection(self, media_type: str, item):
self.collection[media_type] = []
self.collection[media_type].append(item)
+
+ def remove_empty_values(self, result):
+ """
+ Update result to remove empty changes.
+ This makes diagnostic printing cleaner if we don't print "changed: 0"
+ """
+ for change_type in ["added", "existing", "updated"]:
+ for media_type, value in result[change_type].copy().items():
+ if value == 0:
+ del result[change_type][media_type]
+ if len(result[change_type]) == 0:
+ del result[change_type]
+
+ for media_type, items in result["not_found"].copy().items():
+ if len(items) == 0:
+ del result["not_found"][media_type]
+
+ if len(result["not_found"]) == 0:
+ del result["not_found"]
+
+ if len(result) == 0:
+ return None
+
+ return result

Minimize printed result

This is done by removing empty values that have no value when printed