From 839dc938ac4c98d1edf9c757ebe41e8aef970b5d Mon Sep 17 00:00:00 2001 From: Spoked <5782630+dreulavelle@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:58:58 -0500 Subject: [PATCH] Fix update filter. Switch to debug logging. (#22) Co-authored-by: Spoked --- backend/program/content/plex_watchlist.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/program/content/plex_watchlist.py b/backend/program/content/plex_watchlist.py index 1792d195..9a5b1427 100644 --- a/backend/program/content/plex_watchlist.py +++ b/backend/program/content/plex_watchlist.py @@ -33,13 +33,14 @@ def _validate_settings(self): def update_items(self, media_items: MediaItemContainer): """Fetch media from Plex watchlist and add them to media_items attribute if they are not already there""" - logger.info("Getting items...") - watchlist_items = self._get_items_from_plex_watchlist() - container = self.updater.create_items(watchlist_items) + logger.debug("Getting items...") + items = self._get_items_from_plex_watchlist() + new_items = [item for item in items if item not in media_items] + container = self.updater.create_items(new_items) added_items = media_items.extend(container) if len(added_items) > 0: logger.info("Added %s items", len(added_items)) - logger.info("Done!") + logger.debug("Done!") def _get_items_from_plex_watchlist(self) -> list: """Fetch media from Plex watchlist""" @@ -50,4 +51,5 @@ def _get_items_from_plex_watchlist(self) -> list: for item in items: imdb_id = next((guid.split('//')[-1] for guid in item.get('guids') if "imdb://" in guid), None) ids.append(imdb_id) + logger.debug("Found %s items", len(ids)) return ids