From a843303812e940ded5788d4cd99e5a89b16af053 Mon Sep 17 00:00:00 2001 From: Nils Vogels Date: Fri, 2 May 2014 23:58:27 +0200 Subject: [PATCH 1/4] Only log deletion when we're really deleting --- sickbeard/postProcessor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index b4dd21ca..1d93cb81 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -216,8 +216,8 @@ class PostProcessor(object): # delete the file and any other files which we want to delete for cur_file in file_list: - self._log(u"Deleting file " + cur_file, logger.DEBUG) if ek.ek(os.path.isfile, cur_file): + self._log(u"Deleting file " + cur_file, logger.DEBUG) #check first the read-only attribute file_attribute = ek.ek(os.stat, cur_file)[0] if (not file_attribute & stat.S_IWRITE): From 84e2ec6605478a12c824afb2a91437205117ac36 Mon Sep 17 00:00:00 2001 From: Nils Vogels Date: Sat, 3 May 2014 00:08:52 +0200 Subject: [PATCH 2/4] Adding webm as a supported extension --- sickbeard/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sickbeard/common.py b/sickbeard/common.py index 3c4b23bc..f12e7069 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -33,7 +33,7 @@ mediaExtensions = ['avi', 'mkv', 'mpg', 'mpeg', 'wmv', 'ogm', 'mp4', 'iso', 'img', 'divx', 'm2ts', 'm4v', 'ts', 'flv', 'f4v', 'mov', 'rmvb', 'vob', 'dvr-ms', 'wtv', - 'ogv', '3gp'] + 'ogv', '3gp', 'webm'] subtitleExtensions = ['srt', 'sub', 'ass', 'idx', 'ssa'] From ab890846889b9f98afb29e1ef648aadf09507c7e Mon Sep 17 00:00:00 2001 From: Nils Vogels Date: Sat, 3 May 2014 00:28:36 +0200 Subject: [PATCH 3/4] 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 --- lib/tvdb_api/readme.md | 2 +- lib/tvdb_api/tests/test_tvdb_api.py | 5 +++++ lib/tvdb_api/tvdb_api.py | 32 +++++++++++++++++++---------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/tvdb_api/readme.md b/lib/tvdb_api/readme.md index 879390e5..b0b0cfdf 100644 --- a/lib/tvdb_api/readme.md +++ b/lib/tvdb_api/readme.md @@ -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: >>> 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: diff --git a/lib/tvdb_api/tests/test_tvdb_api.py b/lib/tvdb_api/tests/test_tvdb_api.py index a9483620..c1fc66b1 100644 --- a/lib/tvdb_api/tests/test_tvdb_api.py +++ b/lib/tvdb_api/tests/test_tvdb_api.py @@ -99,6 +99,11 @@ class test_tvdb_basic(unittest.TestCase): 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): # Used to store the cached instance of Tvdb() diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index bb503e56..36ba497a 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -96,15 +96,12 @@ class ShowContainer(dict): #keep only the 100th latest results if time.time() - self._lastgc > 20: - tbd = self._stack[:-100] - i = 0 - for o in tbd: + for o in self._stack[:-100]: del self[o] - del self._stack[i] - i += 1 - _lastgc = time.time() - del tbd + self._stack = self._stack[-100:] + + self._lastgc = time.time() super(ShowContainer, self).__setitem__(key, value) @@ -849,11 +846,24 @@ class Tvdb: use_dvd = False if use_dvd: - seas_no = int(cur_ep.find('DVD_season').text) - ep_no = int(float(cur_ep.find('DVD_episodenumber').text)) + elem_seasnum, elem_epno = cur_ep.find('DVD_season'), cur_ep.find('DVD_episodenumber') else: - seas_no = int(cur_ep.find('SeasonNumber').text) - ep_no = int(cur_ep.find('EpisodeNumber').text) + elem_seasnum, elem_epno = cur_ep.find('SeasonNumber'), cur_ep.find('EpisodeNumber') + + 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 From d906bcc049c3f000b3ed41ab43fc382ac3d46e46 Mon Sep 17 00:00:00 2001 From: Nils Vogels Date: Sat, 3 May 2014 00:37:41 +0200 Subject: [PATCH 4/4] Attempt to get quality from snatched episode status Backport from midgetspy --- sickbeard/postProcessor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 1d93cb81..2c2429d7 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -681,7 +681,14 @@ class PostProcessor(object): ep_quality] + ", using that", logger.DEBUG) return ep_quality - # if we didn't get a quality from one of the names above, try assuming from each of the names + # Try getting quality from the episode (snatched) status + if ep_obj.status in common.Quality.SNATCHED + common.Quality.SNATCHED_PROPER: + oldStatus, ep_quality = common.Quality.splitCompositeStatus(ep_obj.status) # @UnusedVariable + if ep_quality != common.Quality.UNKNOWN: + self._log(u"The old status had a quality in it, using that: " + common.Quality.qualityStrings[ep_quality], logger.DEBUG) + return ep_quality + + # Try guessing quality from the file name ep_quality = common.Quality.assumeQuality(self.file_name) self._log( u"Guessing quality for name " + self.file_name + u", got " + common.Quality.qualityStrings[ep_quality],