From 0a50d35f82659a63daa4be0d1a314f054778ab13 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Tue, 21 Aug 2018 02:22:12 +0100 Subject: [PATCH] Fix detection of existing files. Change add sanitize 'imdbid' field in tvdb_api v2. Change indexer_id in imdb_info (switchIndexer). --- CHANGES.md | 9 ++++++++- lib/tvdb_api/tvdb_api.py | 6 ++++++ sickbeard/common.py | 6 ++++-- sickbeard/tv.py | 14 +++++++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 15286106..a35951f9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,11 @@ -### 0.16.22 (2018-08-18 12:30:00 UTC) +### 0.16.23 (2018-08-21 21:00:00 UTC) + +* Fix detection of existing files +* Change add sanitize 'imdbid' field in tvdb_api v2 +* Change indexer_id in imdb_info (switchIndexer) + + +### 0.16.22 (2018-08-18 12:30:00 UTC) * Change TVDB data parsing for gueststars, writers and genre diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index 7040db25..17887813 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -639,6 +639,12 @@ class Tvdb: v = None else: v = None + elif 'imdbid' == k: + if v: + if re.search(r'^(tt)?\d{1,7}$', v, flags=re.I): + v = self._clean_data(v) + else: + v = '' else: v = self._clean_data(v) if k in map_show: diff --git a/sickbeard/common.py b/sickbeard/common.py index 15379a08..29b8e301 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -180,7 +180,8 @@ class Quality: If no quality is achieved it will try sceneQuality regex """ - name = os.path.basename(name) + from sickbeard import encodingKludge as ek + name = ek.ek(os.path.basename, name) # if we have our exact text then assume we put it there for x in sorted(Quality.qualityStrings.keys(), reverse=True): @@ -201,7 +202,8 @@ class Quality: Return The quality from the scene episode File """ - name = os.path.basename(name) + from sickbeard import encodingKludge as ek + name = ek.ek(os.path.basename, name) checkName = lambda quality_list, func: func([re.search(x, name, re.I) for x in quality_list]) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index da9f494f..430441e6 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -823,7 +823,7 @@ class TVShow(object): logger.log('Since this file was renamed, file %s was checked and quality "%s" found' % (file, Quality.qualityStrings[new_quality]), logger.DEBUG) status, quality = sickbeard.common.Quality.splitCompositeStatus(cur_ep.status) - if Quality.UNKNOWN != new_quality or SKIPPED == status: + if Quality.UNKNOWN != new_quality or status in (SKIPPED, UNAIRED): cur_ep.status = Quality.compositeStatus(DOWNLOADED, new_quality) # check for status/quality changes as long as it's a new file @@ -860,6 +860,16 @@ class TVShow(object): % (cur_ep.status, Quality.compositeStatus(new_status, new_quality)), logger.DEBUG) cur_ep.status = Quality.compositeStatus(new_status, new_quality) + elif same_file: + status, quality = Quality.splitCompositeStatus(cur_ep.status) + if status in (SKIPPED, UNAIRED): + new_quality = Quality.nameQuality(file, self.is_anime) + if Quality.UNKNOWN == new_quality: + new_quality = Quality.fileQuality(file) + logger.log('Since this file has status: "%s", file %s was checked and quality "%s" found' + % (statusStrings[status], file, Quality.qualityStrings[new_quality]), logger.DEBUG) + cur_ep.status = Quality.compositeStatus(DOWNLOADED, new_quality) + with cur_ep.lock: result = cur_ep.get_sql() if None is not result: @@ -1355,6 +1365,8 @@ class TVShow(object): self.ids[old_indexer]['status'] = MapStatus.NONE self.ids[self.indexer]['status'] = MapStatus.SOURCE self.ids[self.indexer]['id'] = self.indexerid + if isinstance(self.imdb_info, dict): + self.imdb_info['indexer_id'] = self.indexerid save_mapping(self) name_cache.remove_from_namecache(old_indexerid)