Merge branch 'master' into develop

This commit is contained in:
JackDandy 2017-12-13 02:05:24 +00:00
commit f1bb13c4b3
9 changed files with 60 additions and 28 deletions

View file

@ -1,4 +1,10 @@
### 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
* Change improve usage of the optional regex library
### 0.13.5 (2017-12-11 21:45:00 UTC)
* Change delete unused html5lib files that can cause issue with search providers

View file

@ -58,8 +58,12 @@
</div>
<div id="content_download_propers">
<span class="component-desc">
#if $getVar('using_regex', False)
<p>Optional <a href="https://pypi.python.org/pypi/regex" target="_blank">regex python library</a> is being used</p>
#else
<p>Optional: to improve matching, install the OS dependent <a href="https://pypi.python.org/pypi/regex" target="_blank">regex python library</a></p>
<p>at a command line, simply enter ... <code>python -m pip install regex</code></p>
#end if
</span>
<div class="field-pair">
<label>

View file

@ -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

View file

@ -656,8 +656,13 @@ class ParseResult(object):
if None is regex:
return re.sub(ep_regex, '', e_i_n_n, flags=re.I)
return regex.sub(r'(%s){e<=%d}' % (
ep_regex, trunc(len(re.findall(r'\w', ep_regex)) / 5)), '', e_i_n_n, flags=regex.I | regex.B)
er = trunc(len(re.findall(r'\w', ep_regex)) / 5)
try:
me = trunc(len(e_i_n_n) / 5)
me = min(3, me)
except (StandardError, Exception):
me = 3
return regex.sub(r'(%s){e<=%d}' % (ep_regex, (er, me)[er > me]), '', e_i_n_n, flags=regex.I | regex.B)
def get_extra_info_no_name(self):
extra_info_no_name = self.extra_info

View file

@ -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'

View file

@ -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)

View file

@ -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):

View file

@ -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:

View file

@ -4976,6 +4976,12 @@ class ConfigSearch(Config):
show.rls_require_words.strip()]
t.using_rls_require_words.sort(lambda x, y: cmp(x[1], y[1]), reverse=False)
t.propers_intervals = search_propers.ProperSearcher().search_intervals
t.using_regex = False
try:
from sickbeard.name_parser.parser import regex
t.using_regex = None is not regex
except (StandardError, Exception):
pass
return t.respond()
def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None,