From f39afd1c0ef47aecfafa970ccd8e9460b36d8753 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Thu, 17 May 2018 01:32:23 +0200 Subject: [PATCH] Change improve tvdb_api performance; remember if episodes are cached and reload show if not and episodes are requested. --- CHANGES.md | 1 + lib/tvdb_api/tvdb_api.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 246272c8..b4834257 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ 'scene releases (srrDB/predb listed)', 'or contain' text or regex, 'non scene if no recent search results', 'non scene if no active search results', 'not scene nuked', and 'nuked if no active search results' +* Change improve tvdb_api performance; remember if episodes are cached and reload show if not and episodes are requested [develop changelog] diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index 909b1155..f2cb7b8d 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -122,6 +122,7 @@ class Show(dict): def __init__(self): dict.__init__(self) self.data = {} + self.ep_loaded = False def __repr__(self): return '' % (self.data.get(u'seriesname', 'instance'), len(self)) @@ -857,6 +858,9 @@ class Tvdb: for k, v in show_data['data'].iteritems(): self._set_show_data(sid, k, v) + if sid in self.shows: + self.shows[sid].ep_loaded = get_ep_info + p = '' if self.config['posters_enabled']: poster_data = self._getetsrc(self.config['url_seriesBanner'] % (sid, 'poster'), language=language) @@ -998,7 +1002,7 @@ class Tvdb: if isinstance(key, (int, long)): # Item is integer, treat as show id - if key not in self.shows: + if key not in self.shows or (not self.shows[key].ep_loaded and arg in (None, True)): self._get_show_data(key, self.config['language'], (True, arg)[arg is not None]) return None if key not in self.shows else self.shows[key]