mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-07 11:58:01 -05:00
tvdb_api update, backport from midgetspy
* Skip episodes which are missing SeasonNumber or Episode Number (or DVD_season or DVD_episodenumber) * Avoid excessive calls to the ShowContainer garbage collection * fix ShowContainer cache resizing
This commit is contained in:
parent
84e2ec6605
commit
ab89084688
@ -63,7 +63,7 @@ For example, to find out what network Scrubs is aired:
|
|||||||
The data is stored in an attribute named `data`, within the Show instance:
|
The data is stored in an attribute named `data`, within the Show instance:
|
||||||
|
|
||||||
>>> t['scrubs'].data.keys()
|
>>> t['scrubs'].data.keys()
|
||||||
['networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'ratingcount', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'firstaired', 'runtime', 'overview']
|
['networkid', 'rating', 'airs_dayofweek', 'contentrating', 'seriesname', 'id', 'airs_time', 'network', 'fanart', 'lastupdated', 'actors', 'ratingcount', 'status', 'added', 'poster', 'imdb_id', 'genre', 'banner', 'seriesid', 'language', 'zap2it_id', 'addedby', 'tms_wanted', 'firstaired', 'runtime', 'overview']
|
||||||
|
|
||||||
Although each element is also accessible via `t['scrubs']` for ease-of-use:
|
Although each element is also accessible via `t['scrubs']` for ease-of-use:
|
||||||
|
|
||||||
|
@ -99,6 +99,11 @@ class test_tvdb_basic(unittest.TestCase):
|
|||||||
show
|
show
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_no_season(self):
|
||||||
|
show = self.t['Katekyo Hitman Reborn']
|
||||||
|
print tvdb_api
|
||||||
|
print show[1][1]
|
||||||
|
|
||||||
|
|
||||||
class test_tvdb_errors(unittest.TestCase):
|
class test_tvdb_errors(unittest.TestCase):
|
||||||
# Used to store the cached instance of Tvdb()
|
# Used to store the cached instance of Tvdb()
|
||||||
|
@ -96,15 +96,12 @@ class ShowContainer(dict):
|
|||||||
|
|
||||||
#keep only the 100th latest results
|
#keep only the 100th latest results
|
||||||
if time.time() - self._lastgc > 20:
|
if time.time() - self._lastgc > 20:
|
||||||
tbd = self._stack[:-100]
|
for o in self._stack[:-100]:
|
||||||
i = 0
|
|
||||||
for o in tbd:
|
|
||||||
del self[o]
|
del self[o]
|
||||||
del self._stack[i]
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
_lastgc = time.time()
|
self._stack = self._stack[-100:]
|
||||||
del tbd
|
|
||||||
|
self._lastgc = time.time()
|
||||||
|
|
||||||
super(ShowContainer, self).__setitem__(key, value)
|
super(ShowContainer, self).__setitem__(key, value)
|
||||||
|
|
||||||
@ -849,11 +846,24 @@ class Tvdb:
|
|||||||
use_dvd = False
|
use_dvd = False
|
||||||
|
|
||||||
if use_dvd:
|
if use_dvd:
|
||||||
seas_no = int(cur_ep.find('DVD_season').text)
|
elem_seasnum, elem_epno = cur_ep.find('DVD_season'), cur_ep.find('DVD_episodenumber')
|
||||||
ep_no = int(float(cur_ep.find('DVD_episodenumber').text))
|
|
||||||
else:
|
else:
|
||||||
seas_no = int(cur_ep.find('SeasonNumber').text)
|
elem_seasnum, elem_epno = cur_ep.find('SeasonNumber'), cur_ep.find('EpisodeNumber')
|
||||||
ep_no = int(cur_ep.find('EpisodeNumber').text)
|
|
||||||
|
if elem_seasnum is None or elem_epno is None:
|
||||||
|
|
||||||
|
log().warning("An episode has incomplete season/episode number (season: %r, episode: %r)" % (
|
||||||
|
elem_seasnum, elem_epno))
|
||||||
|
log().debug(
|
||||||
|
" ".join(
|
||||||
|
"%r is %r" % (child.tag, child.text) for child in cur_ep.getchildren()))
|
||||||
|
# TODO: Should this happen?
|
||||||
|
continue # Skip to next episode
|
||||||
|
|
||||||
|
|
||||||
|
# float() is because https://github.com/dbr/tvnamer/issues/95 - should probably be fixed in TVDB data
|
||||||
|
seas_no = int(float(elem_seasnum.text))
|
||||||
|
ep_no = int(float(elem_epno.text))
|
||||||
|
|
||||||
useDVD = False
|
useDVD = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user