Change improve tvdb_api performance; remember if episodes are cached and reload show if not and episodes are requested.

This commit is contained in:
Prinz23 2018-05-17 01:32:23 +02:00 committed by JackDandy
parent ccec551726
commit f39afd1c0e
2 changed files with 6 additions and 1 deletions

View file

@ -9,6 +9,7 @@
'scene releases (srrDB/predb listed)', 'or contain' text or regex, 'scene releases (srrDB/predb listed)', 'or contain' text or regex,
'non scene if no recent search results', 'non scene if no active search results', 'non scene if no recent search results', 'non scene if no active search results',
'not scene nuked', and 'nuked 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] [develop changelog]

View file

@ -122,6 +122,7 @@ class Show(dict):
def __init__(self): def __init__(self):
dict.__init__(self) dict.__init__(self)
self.data = {} self.data = {}
self.ep_loaded = False
def __repr__(self): def __repr__(self):
return '<Show %r (containing %s seasons)>' % (self.data.get(u'seriesname', 'instance'), len(self)) return '<Show %r (containing %s seasons)>' % (self.data.get(u'seriesname', 'instance'), len(self))
@ -857,6 +858,9 @@ class Tvdb:
for k, v in show_data['data'].iteritems(): for k, v in show_data['data'].iteritems():
self._set_show_data(sid, k, v) self._set_show_data(sid, k, v)
if sid in self.shows:
self.shows[sid].ep_loaded = get_ep_info
p = '' p = ''
if self.config['posters_enabled']: if self.config['posters_enabled']:
poster_data = self._getetsrc(self.config['url_seriesBanner'] % (sid, 'poster'), language=language) poster_data = self._getetsrc(self.config['url_seriesBanner'] % (sid, 'poster'), language=language)
@ -998,7 +1002,7 @@ class Tvdb:
if isinstance(key, (int, long)): if isinstance(key, (int, long)):
# Item is integer, treat as show id # 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]) 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] return None if key not in self.shows else self.shows[key]