mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2025-02-16 22:08:25 +00:00
[13] #831 cache fetched items
This commit is contained in:
parent
e887bcbffb
commit
182f977a91
3 changed files with 7 additions and 2 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.16.5-develop12
|
1.16.5-develop13
|
||||||
|
|
|
@ -1955,9 +1955,13 @@ class CollectionBuilder:
|
||||||
|
|
||||||
def fetch_item(self, item):
|
def fetch_item(self, item):
|
||||||
try:
|
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)):
|
if not isinstance(current, (Movie, Show, Season, Episode, Artist, Album, Track)):
|
||||||
raise NotFound
|
raise NotFound
|
||||||
|
self.library.cached_items[key] = current
|
||||||
return current
|
return current
|
||||||
except (BadRequest, NotFound):
|
except (BadRequest, NotFound):
|
||||||
raise Failed(f"Plex Error: Item {item} not found")
|
raise Failed(f"Plex Error: Item {item} not found")
|
||||||
|
|
|
@ -357,6 +357,7 @@ class Plex(Library):
|
||||||
|
|
||||||
self._users = []
|
self._users = []
|
||||||
self._all_items = []
|
self._all_items = []
|
||||||
|
self.cached_items = {}
|
||||||
self.agent = self.Plex.agent
|
self.agent = self.Plex.agent
|
||||||
self.is_movie = self.type == "Movie"
|
self.is_movie = self.type == "Movie"
|
||||||
self.is_show = self.type == "Show"
|
self.is_show = self.type == "Show"
|
||||||
|
|
Loading…
Add table
Reference in a new issue