From: Ztripez Date: Sat, 22 Mar 2025 17:14:43 +0000 (+0100) Subject: Audible: fixes pagination logic error is a users library have sub 50 items (#2055) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=93c6e7379c9f2a01a9a7200301118742e106e788;p=music-assistant-server.git Audible: fixes pagination logic error is a users library have sub 50 items (#2055) --- diff --git a/music_assistant/providers/audible/audible_helper.py b/music_assistant/providers/audible/audible_helper.py index fd8a1953..0f997976 100644 --- a/music_assistant/providers/audible/audible_helper.py +++ b/music_assistant/providers/audible/audible_helper.py @@ -36,7 +36,6 @@ CACHE_CATEGORY_API = 0 CACHE_CATEGORY_AUDIOBOOK = 1 CACHE_CATEGORY_CHAPTERS = 2 -# Cache for authenticator objects to avoid repeated file reads _AUTH_CACHE: dict[str, audible.Authenticator] = {} @@ -112,10 +111,9 @@ class AudibleHelper: "Audible: Got %s items (total reported by API: %s)", len(items), total_items ) - if not items or len(items) < page_size: + if not items: self.logger.debug( - "Audible: No more items or fewer than page size returned, " - "ending pagination (processed %s items)", + "Audible: No more items returned, ending pagination (processed %s items)", total_processed, ) break @@ -164,6 +162,14 @@ class AudibleHelper: total_items, ) + if len(items) < page_size: + self.logger.debug( + "Audible: Fewer than page size returned, " + "ending pagination (processed %s items)", + total_processed, + ) + break + if iteration >= max_iterations: self.logger.warning( "Audible: Reached maximum iteration limit (%s) with %s items processed",