From 0204ac9dd701e581ba8c81b9b2508ced6ba89c2f Mon Sep 17 00:00:00 2001 From: SickGear Date: Mon, 27 Jan 2020 09:01:18 +0000 Subject: [PATCH] Fix issue processing files with no quality parsed. Change remove nonsense text that quality of pp item is from snatch history given that it may not be. Fix update NameCache in case show name changes. Fix removal of old entry in NameCache when changing specific show and when removing show. Add thread lock when adding/removing items from NameCache. --- CHANGES.md | 9 ++++++++- sickbeard/name_cache.py | 32 +++++++++++++++++++------------- sickbeard/postProcessor.py | 8 ++++---- sickbeard/providers/omgwtfnzbs.py | 3 +++ sickbeard/tv_base.py | 4 ++++ 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 13f5179..ccbb7e0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,11 @@ -### 0.21.7 (2020-01-24 15:05:00 UTC) +### 0.21.8 (2020-01-27 09:00:00 UTC) + +* Fix issue processing files with no quality parsed +* Change remove nonsense text that quality of pp item is from snatch history given that it may not be +* Fix update NameCache in case show name changes + + +### 0.21.7 (2020-01-24 15:05:00 UTC) * Fix rTorrent py3 compat * Fix edit show with multiple list values under py3 diff --git a/sickbeard/name_cache.py b/sickbeard/name_cache.py index 7b7b69b..f1207f5 100644 --- a/sickbeard/name_cache.py +++ b/sickbeard/name_cache.py @@ -22,12 +22,12 @@ import sickbeard from . import db from .helpers import try_int -from _23 import list_items from six import iteritems # noinspection PyUnreachableCode if False: - from typing import AnyStr, Tuple, Union + from typing import AnyStr, Optional, Tuple, Union + from .tv import TVShow, TVShowBase nameCache = {} nameCacheLock = threading.Lock() @@ -47,10 +47,11 @@ def addNameToCache(name, tvid=0, prodid=0, season=-1): """ global nameCache - # standardize the name we're using to account for small differences in providers - name = sickbeard.helpers.full_sanitize_scene_name(name) - if name not in nameCache: - nameCache[name] = [int(tvid), int(prodid), season] + with nameCacheLock: + # standardize the name we're using to account for small differences in providers + name = sickbeard.helpers.full_sanitize_scene_name(name) + if name not in nameCache: + nameCache[name] = [int(tvid), int(prodid), season] def retrieveNameFromCache(name): @@ -63,16 +64,19 @@ def retrieveNameFromCache(name): global nameCache name = sickbeard.helpers.full_sanitize_scene_name(name) - if name in nameCache: - return int(nameCache[name][0]), int(nameCache[name][1]) + try: + if name in nameCache: + return int(nameCache[name][0]), int(nameCache[name][1]) + except (BaseException, Exception): + pass return None, None def buildNameCache(show_obj=None): + # type: (Optional[Union[TVShow, TVShowBase]]) -> None """Adds all new name exceptions to the namecache memory and flushes any removed name exceptions - :param show_obj : (optional) Only update namecache for this show object - :type show_obj: sickbeard.tv.TVShow or None + :param show_obj : Only update name cache for this show object, otherwise update all """ global nameCache with nameCacheLock: @@ -80,7 +84,8 @@ def buildNameCache(show_obj=None): if show_obj: # search for only the requested show id and flush old show entries from namecache show_ids = {show_obj.tvid: [show_obj.prodid]} - nameCache = dict([(k, v) for k, v in list_items(nameCache) if v != (show_obj.tvid, show_obj.prodid)]) + nameCache = dict([(k, v) for k, v in iteritems(nameCache) + if not (v[0] == show_obj.tvid and v[1] == show_obj.prodid)]) # add standard indexer name to namecache nameCache[sickbeard.helpers.full_sanitize_scene_name(show_obj.name)] = [show_obj.tvid, show_obj.prodid, -1] @@ -123,5 +128,6 @@ def remove_from_namecache(tvid, prodid): """ global nameCache - if nameCache: - nameCache = dict([(k, v) for k, v in list_items(nameCache) if v != (tvid, prodid)]) + with nameCacheLock: + if nameCache: + nameCache = dict([(k, v) for k, v in iteritems(nameCache) if not (v[0] == tvid and v[1] == prodid)]) diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 3de9972..480fc1f 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -66,7 +66,8 @@ class PostProcessor(object): nzb_name: The name of the NZB which resulted in this file being downloaded (optional) """ # absolute path to the folder that is being processed - self.folder_path = long_path(ek.ek(os.path.dirname, long_path(ek.ek(os.path.abspath, long_path(file_path))))) # type: AnyStr + self.folder_path = long_path(ek.ek(os.path.dirname, long_path( + ek.ek(os.path.abspath, long_path(file_path))))) # type: AnyStr # full path to file self.file_path = long_path(file_path) # type: AnyStr @@ -1032,12 +1033,11 @@ class PostProcessor(object): ep_obj = self._get_ep_obj(show_obj, season_number, episode_numbers) # get the quality of the episode we're processing - if common.Quality.UNKNOWN == quality: + if quality in (None, common.Quality.UNKNOWN): new_ep_quality = self._get_quality(ep_obj) else: new_ep_quality = quality - self._log(u'Using "%s" quality from the snatch history' - % common.Quality.qualityStrings[new_ep_quality], logger.DEBUG) + self._log(u'Using "%s" quality' % common.Quality.qualityStrings[new_ep_quality], logger.DEBUG) # see if it's safe to replace existing episode (is download snatched, PROPER, better quality) if not self._safe_replace(ep_obj, new_ep_quality): diff --git a/sickbeard/providers/omgwtfnzbs.py b/sickbeard/providers/omgwtfnzbs.py index a4b59a5..40198c8 100644 --- a/sickbeard/providers/omgwtfnzbs.py +++ b/sickbeard/providers/omgwtfnzbs.py @@ -55,6 +55,7 @@ class OmgwtfnzbsProvider(generic.NZBProvider): 'search_html': self.url_base + 'browse.php?cat=tv&search=%s'} # type: Dict[AnyStr, AnyStr] self.needs_auth = True # type: bool + self.nn = True # type: bool self.username, self.api_key, self.cookies = 3 * [None] self.cache = OmgwtfnzbsCache(self) @@ -395,6 +396,8 @@ class OmgwtfnzbsProvider(generic.NZBProvider): self.cookies = re.sub(r'(?i)([\s\']+|cookie\s*:)', '', api_key) success, msg = self._check_cookie() + if success and self.nn: + success, msg = None, 'pm dev in irc about this feature' if not success: logger.log(u'%s: %s' % (msg, self.cookies), logger.WARNING) self.cookies = None diff --git a/sickbeard/tv_base.py b/sickbeard/tv_base.py index a4cc1ce..6fb4516 100644 --- a/sickbeard/tv_base.py +++ b/sickbeard/tv_base.py @@ -20,6 +20,7 @@ import sickbeard from . import logger from ._legacy_classes import LegacyTVShow, LegacyTVEpisode from .common import UNKNOWN +from .name_cache import buildNameCache from six import string_types @@ -92,7 +93,10 @@ class TVShowBase(LegacyTVShow, TVBase): @name.setter def name(self, *arg): + _current_name = self._name self.dirty_setter('_name')(self, *arg) + if _current_name != self._name: + buildNameCache(self) # imdbid = property(lambda self: self._imdbid, dirty_setter('_imdbid')) @property