Cache __len__ for the duration of the all() run
Otherwise progress-bar and all() both make the extra API call
@@ -355,6 +355,7 @@ class PlexLibrarySection:
def __init__(self, section: LibrarySection):
self.section = section
+ @memoize
@nocache
def __len__(self):
return self.section.totalSize
@@ -381,6 +382,9 @@ def all(self):
if start > length:
break
+ # clear cached value for next call to all() to be accurate if library changes
+ self.__len__.cache_clear()
+
@nocache
def fetch_items(self, key: str, size: int, start: int):
return self.section.fetchItems(key, container_start=start, container_size=size)
