[13] #831 cache fetched items

This commit is contained in:
meisnate12 2022-04-20 14:19:58 -04:00
parent e887bcbffb
commit 182f977a91
3 changed files with 7 additions and 2 deletions

View file

@ -1 +1 @@
1.16.5-develop12
1.16.5-develop13

View file

@ -1955,9 +1955,13 @@ class CollectionBuilder:
def fetch_item(self, item):
try:
current = self.library.fetchItem(item.ratingKey if isinstance(item, (Movie, Show, Season, Episode, Artist, Album, Track)) else int(item))
key = item.ratingKey if isinstance(item, (Movie, Show, Season, Episode, Artist, Album, Track)) else int(item)
if key in self.library.cached_items:
return self.library.cached_items[key]
current = self.library.fetchItem(key)
if not isinstance(current, (Movie, Show, Season, Episode, Artist, Album, Track)):
raise NotFound
self.library.cached_items[key] = current
return current
except (BadRequest, NotFound):
raise Failed(f"Plex Error: Item {item} not found")

View file

@ -357,6 +357,7 @@ class Plex(Library):
self._users = []
self._all_items = []
self.cached_items = {}
self.agent = self.Plex.agent
self.is_movie = self.type == "Movie"
self.is_show = self.type == "Show"