From 1d552c6dc47ad5007d7c6cbdc197e5c0b67d5a69 Mon Sep 17 00:00:00 2001 From: DraftKinner <196864209+DraftKinner@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:03:49 -0500 Subject: [PATCH] Add exception handling for empty collections when scanning libraries --- zotify/app.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/zotify/app.py b/zotify/app.py index 0f8bdc0..90eac9a 100644 --- a/zotify/app.py +++ b/zotify/app.py @@ -254,17 +254,29 @@ class App: def scan(self, collections: list[Collection]): if self.__config.skip_previous: for collection in collections: - existing = collection.get_existing(self.__config.audio_format.value.ext) - self.__existing.update(existing) + try: + existing = collection.get_existing( + self.__config.audio_format.value.ext + ) + self.__existing.update(existing) + except IndexError as err: + Logger.log( + LogChannel.WARNINGS, f"{err} Cannot scan for existing tracks" + ) if self.__config.skip_duplicates: for collection in collections: - duplicates = collection.get_duplicates( - self.__config.audio_format.value.ext, - self.__config.album_library, - self.__config.playlist_library, - self.__config.podcast_library, - ) - self.__duplicates.update(duplicates) + try: + duplicates = collection.get_duplicates( + self.__config.audio_format.value.ext, + self.__config.album_library, + self.__config.playlist_library, + self.__config.podcast_library, + ) + self.__duplicates.update(duplicates) + except IndexError as err: + Logger.log( + LogChannel.WARNINGS, f"{err} Cannot scan for duplicate tracks" + ) def download_all(self, collections: list[Collection]) -> None: self.rate_limit_hits = 0