Change skip episodes that have no wanted qualities.

Change download picked .nzb file on demand and not before.
This commit is contained in:
Prinz23 2017-02-13 20:00:55 +00:00 committed by JackDandy
parent bc7b6ff2dc
commit b56ddd2eec
6 changed files with 52 additions and 17 deletions

View file

@ -1,4 +1,10 @@
### 0.12.5 (2017-01-16 16:22:00 UTC)
### 0.12.6 (2017-02-17 03:48:00 UTC)
* Change skip episodes that have no wanted qualities
* Change download picked .nzb file on demand and not before
### 0.12.5 (2017-01-16 16:22:00 UTC)
* Change TD search URL
* Fix saving Media Providers when either Search NZBs/Torrents is disabled

View file

@ -45,6 +45,9 @@ class SearchResult:
# used by some providers to store extra info associated with the result
self.extraInfo = []
# assign function to get the data for the download
self.get_data_func = None
# list of TVEpisode objects that this result is associated with
self.episodes = episodes
@ -83,6 +86,15 @@ class SearchResult:
def fileName(self):
return self.episodes[0].prettyName() + '.' + self.resultType
def get_data(self):
if None is not self.get_data_func:
try:
return self.get_data_func(self.url)
except (StandardError, Exception):
pass
if self.extraInfo and 0 < len(self.extraInfo):
return self.extraInfo[0]
return None
class NZBSearchResult(SearchResult):
"""

View file

@ -95,7 +95,9 @@ def send_nzb(nzb, proper=False):
nzbcontent64 = None
if 'nzbdata' == nzb.resultType:
data = nzb.extraInfo[0]
data = nzb.get_data()
if not data:
return False
nzbcontent64 = standard_b64encode(data)
elif 'Anizb' == nzb.provider.name and 'nzb' == nzb.resultType:
gen_provider = GenericProvider('')

View file

@ -92,21 +92,26 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
return item['release'].replace('_', '.'), item['getnzb']
def get_data(self, url):
result = None
if url and False is self._init_api():
data = self.get_url(url, timeout=90)
if data:
if re.search('(?i)limit.*?reached', data):
logger.log('Daily Nzb Download limit reached', logger.DEBUG)
elif '</nzb>' not in data or 'seem to be logged in' in data:
logger.log('Failed nzb data response: %s' % data, logger.DEBUG)
else:
result = data
return result
def get_result(self, episodes, url):
result = None
if url and False is self._init_api():
data = self.get_url(url, timeout=90)
if not data:
return result
if '<strong>Limit Reached</strong>' in data:
logger.log('Daily Nzb Download limit reached', logger.DEBUG)
return result
if '</nzb>' not in data or 'seem to be logged in' in data:
logger.log('Failed nzb data response: %s' % data, logger.DEBUG)
return result
result = classes.NZBDataSearchResult(episodes)
result.extraInfo += [data]
result.get_data_func = self.get_data
result.url = url
if None is result:
result = classes.NZBSearchResult(episodes)
@ -193,7 +198,7 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
if tr.find('img', src=rc['nuked']) or not tr.find('a', href=rc['cat']):
continue
title = tr.find('a', href=rc['info'])['title']
title = tr.find('a', href=rc['info']).get_text().strip()
download_url = tr.find('a', href=rc['get'])
age = tr.find_all('td')[-1]['data-sort']
except (AttributeError, TypeError, ValueError):

View file

@ -60,7 +60,10 @@ def send_nzb(nzb):
nzb_type = 'file nzb'
params['mode'] = 'addfile'
kwargs['post_data'] = params
kwargs['files'] = {'nzbfile': ('%s.nzb' % nzb.name, nzb.extraInfo[0])}
nzb_data = nzb.get_data()
if not nzb_data:
return False
kwargs['files'] = {'nzbfile': ('%s.nzb' % nzb.name, nzb_data)}
logger.log(u'Sending %s to SABnzbd: %s' % (nzb_type, nzb.name))

View file

@ -72,10 +72,14 @@ def _download_result(result):
# save the data to disk
try:
with ek.ek(open, file_name, 'w') as file_out:
file_out.write(result.extraInfo[0])
data = result.get_data()
if not data:
new_result = False
else:
with ek.ek(open, file_name, 'w') as file_out:
file_out.write(data)
helpers.chmodAsParent(file_name)
helpers.chmodAsParent(file_name)
except EnvironmentError as e:
logger.log(u'Error trying to save NZB to black hole: %s' % ex(e), logger.ERROR)
@ -388,6 +392,9 @@ def wanted_episodes(show, from_date, make_dict=False, unaired=False):
ep_obj = show.getEpisode(int(result['season']), int(result['episode']))
ep_obj.wantedQuality = [i for i in (wanted_qualities, initial_qualities)[not_downloaded]
if cur_quality < i]
# in case we don't want any quality for this episode, skip the episode
if 0 == len(ep_obj.wantedQuality):
continue
ep_obj.eps_aired_in_season = ep_count.get(helpers.tryInt(result['season']), 0)
ep_obj.eps_aired_in_scene_season = ep_count_scene.get(
helpers.tryInt(result['scene_season']), 0) if result['scene_season'] else ep_obj.eps_aired_in_season