diff --git a/CHANGES.md b/CHANGES.md index 845be784..d6662e80 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 0.13.5 (2017-12-11 21:45:00 UTC) +### 0.13.6 (2017-12-13 01:50:00 UTC) + +* Change improve multi episode release search + + +### 0.13.5 (2017-12-11 21:45:00 UTC) * Change delete unused html5lib files that can cause issue with search providers diff --git a/sickbeard/common.py b/sickbeard/common.py index a13c5309..44333e77 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -462,7 +462,7 @@ countryList = {'Australia': 'AU', 'USA': 'US'} -class neededQualities: +class neededQualities(object): def __init__(self, need_anime=False, need_sports=False, need_sd=False, need_hd=False, need_uhd=False, need_webdl=False, need_all_qualities=False, need_all_types=False, need_all=False): self.need_anime = need_anime or need_all_types or need_all @@ -489,21 +489,27 @@ class neededQualities: def all_qualities_needed(self): return self.need_sd and self.need_hd and self.need_uhd and self.need_webdl + @all_qualities_needed.setter + def all_qualities_needed(self, v): + if isinstance(v, bool) and True is v: + self.need_sd = self.need_hd = self.need_uhd = self.need_webdl = True + def check_needed_types(self, show): - if show.is_anime: + if getattr(show, 'is_anime', False): self.need_anime = True - if show.is_sports: + if getattr(show, 'is_sports', False): self.need_sports = True - def check_needed_qualities(self, wantedQualities): - if Quality.UNKNOWN in wantedQualities: - self.need_sd = self.need_hd = self.need_uhd = self.need_webdl = True - else: - if not self.need_sd and min(wantedQualities) <= neededQualities.max_sd: - self.need_sd = True - if not self.need_hd and any(i in neededQualities.hd_qualities for i in wantedQualities): - self.need_hd = True - if not self.need_webdl and any(i in neededQualities.webdl_qualities for i in wantedQualities): - self.need_webdl = True - if not self.need_uhd and max(wantedQualities) > neededQualities.max_hd: - self.need_uhd = True + def check_needed_qualities(self, wanted_qualities): + if wanted_qualities: + if Quality.UNKNOWN in wanted_qualities: + self.need_sd = self.need_hd = self.need_uhd = self.need_webdl = True + else: + if not self.need_sd and min(wanted_qualities) <= neededQualities.max_sd: + self.need_sd = True + if not self.need_hd and any(i in neededQualities.hd_qualities for i in wanted_qualities): + self.need_hd = True + if not self.need_webdl and any(i in neededQualities.webdl_qualities for i in wanted_qualities): + self.need_webdl = True + if not self.need_uhd and max(wanted_qualities) > neededQualities.max_hd: + self.need_uhd = True diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 7339109a..1658eb3a 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -562,10 +562,13 @@ class GenericProvider: # make sure we want the episode want_ep = True + multi_ep = False for epNo in actual_episodes: - if not show_obj.wantEpisode(actual_season, epNo, quality, manual_search): - want_ep = False + want_ep = show_obj.wantEpisode(actual_season, epNo, quality, manual_search, multi_ep) + if not want_ep: break + # after initial single ep perspective, prepare multi ep for subsequent iterations + multi_ep = 1 < actual_episodes if not want_ep: logger.log(u'Ignoring result %s because we don\'t want an episode that is %s' diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index 1cf31c17..e59612c7 100755 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -652,7 +652,8 @@ class NewznabProvider(generic.NZBProvider): base_params['cat'] = ','.join(sorted(set((self.cat_ids.split(',') if self.cat_ids else []) + cat))) request_params = base_params.copy() - if 'Propers' == mode and 'q' in params and not (any(x in params for x in ['season', 'ep'])): + if ('Propers' == mode or 'nzbs_org' == self.get_id()) \ + and 'q' in params and not (any(x in params for x in ['season', 'ep'])): request_params['t'] = 'search' request_params.update(params) diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index db861e91..2fb31373 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -171,7 +171,7 @@ class ThePirateBayProvider(generic.TorrentProvider): return super(ThePirateBayProvider, self)._episode_strings( ep_obj, date_or=True, - ep_detail=lambda x: '%s|%s' % (config.naming_ep_type[2] % x, config.naming_ep_type[0] % x), + ep_detail=lambda x: '%s*|%s*' % (config.naming_ep_type[2] % x, config.naming_ep_type[0] % x), ep_detail_anime=lambda x: '%02i' % x, **kwargs) def _search_provider(self, search_params, search_mode='eponly', epcount=0, **kwargs): diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 4861071d..4a557354 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1446,10 +1446,10 @@ class TVShow(object): + 'sports: %s\n' % self.is_sports \ + 'anime: %s\n' % self.is_anime - def wantEpisode(self, season, episode, quality, manualSearch=False): + def wantEpisode(self, season, episode, quality, manualSearch=False, multi_ep=False): - logger.log('Checking if found episode %sx%s is wanted at quality %s' % - (season, episode, Quality.qualityStrings[quality]), logger.DEBUG) + logger.log('Checking if found %sepisode %sx%s is wanted at quality %s' % + (('', 'multi-part ')[multi_ep], season, episode, Quality.qualityStrings[quality]), logger.DEBUG) # if the quality isn't one we want under any circumstances then just say no initialQualities, archiveQualities = Quality.splitQuality(self.quality) @@ -1479,13 +1479,14 @@ class TVShow(object): logger.log('Existing episode status: %s (%s)' % (statusStrings[curStatus], epStatus_text), logger.DEBUG) # if we know we don't want it then just say no - if curStatus in (SKIPPED, IGNORED, ARCHIVED) and not manualSearch: - logger.log('Existing episode status is skipped/ignored/archived, ignoring found episode', logger.DEBUG) + if curStatus in [IGNORED, ARCHIVED] + ([SKIPPED], [])[multi_ep] and not manualSearch: + logger.log('Existing episode status is %signored/archived, ignoring found episode' % + ('skipped/', '')[multi_ep], logger.DEBUG) return False # if it's one of these then we want it as long as it's in our allowed initial qualities if quality in allQualities: - if curStatus in (WANTED, UNAIRED, SKIPPED, FAILED): + if curStatus in [WANTED, UNAIRED, SKIPPED, FAILED] + ([], SNATCHED_ANY)[multi_ep]: logger.log('Existing episode status is wanted/unaired/skipped/failed, getting found episode', logger.DEBUG) return True elif manualSearch: