Browse Source

Use season/episode information from Newznab and store results

Getting it from the feed is much faster (50x)
tags/1.2.0Beta1 1.2.0Beta1
Safihre 8 years ago
parent
commit
5948d6cf33
  1. 29
      sabnzbd/rss.py

29
sabnzbd/rss.py

@ -418,7 +418,7 @@ class RSSQueue(object):
if readout: if readout:
try: try:
link, category, size, age = _get_link(uri, entry) link, category, size, age, season, episode = _get_link(uri, entry)
except (AttributeError, IndexError): except (AttributeError, IndexError):
link = None link = None
category = u'' category = u''
@ -436,6 +436,8 @@ class RSSQueue(object):
title = jobs[link].get('title', '') title = jobs[link].get('title', '')
size = jobs[link].get('size', 0L) size = jobs[link].get('size', 0L)
age = jobs[link].get('age') age = jobs[link].get('age')
season = jobs[link].get('season', 0)
episode = jobs[link].get('episode', 0)
if link: if link:
# Make sure spaces are quoted in the URL # Make sure spaces are quoted in the URL
@ -456,12 +458,10 @@ class RSSQueue(object):
myScript = defScript myScript = defScript
myPrio = defPrio myPrio = defPrio
n = 0 n = 0
if 'F' in reTypes or 'S' in reTypes: if ('F' in reTypes or 'S' in reTypes) and (not season or not episode):
season, episode = sabnzbd.newsunpack.analyse_show(title)[1:3] season, episode = sabnzbd.newsunpack.analyse_show(title)[1:3]
season = int_conv(season) season = int_conv(season)
episode = int_conv(episode) episode = int_conv(episode)
else:
season = episode = 0
# Match against all filters until an positive or negative match # Match against all filters until an positive or negative match
logging.debug('Size %s for %s', size, title) logging.debug('Size %s for %s', size, title)
@ -547,12 +547,12 @@ class RSSQueue(object):
else: else:
star = first star = first
if result: if result:
_HandleLink(jobs, link, title, size, age, 'G', category, myCat, myPP, myScript, _HandleLink(jobs, link, title, size, age, season, episode, 'G', category, myCat, myPP, myScript,
act, star, order, priority=myPrio, rule=str(n)) act, star, order, priority=myPrio, rule=str(n))
if act: if act:
new_downloads.append(title) new_downloads.append(title)
else: else:
_HandleLink(jobs, link, title, size, age, 'B', category, myCat, myPP, myScript, _HandleLink(jobs, link, title, size, age, season, episode, 'B', category, myCat, myPP, myScript,
False, star, order, priority=myPrio, rule=str(n)) False, star, order, priority=myPrio, rule=str(n))
order += 1 order += 1
@ -641,7 +641,7 @@ class RSSQueue(object):
self.jobs[feed][item]['status'] = 'D-' self.jobs[feed][item]['status'] = 'D-'
def _HandleLink(jobs, link, title, size, age, flag, orgcat, cat, pp, script, download, star, def _HandleLink(jobs, link, title, size, age, season, episode, flag, orgcat, cat, pp, script, download, star,
order, priority=NORMAL_PRIORITY, rule=0): order, priority=NORMAL_PRIORITY, rule=0):
""" Process one link """ """ Process one link """
if script == '': if script == '':
@ -654,6 +654,8 @@ def _HandleLink(jobs, link, title, size, age, flag, orgcat, cat, pp, script, dow
jobs[link]['orgcat'] = orgcat jobs[link]['orgcat'] = orgcat
jobs[link]['size'] = size jobs[link]['size'] = size
jobs[link]['age'] = age jobs[link]['age'] = age
jobs[link]['season'] = season
jobs[link]['episode'] = episode
if special_rss_site(link): if special_rss_site(link):
nzbname = None nzbname = None
else: else:
@ -685,7 +687,7 @@ def _get_link(uri, entry):
""" Retrieve the post link from this entry """ Retrieve the post link from this entry
Returns (link, category, size) Returns (link, category, size)
""" """
link = None # @UnusedVariable -- pep8 bug? link = None
category = '' category = ''
size = 0L size = 0L
uri = uri.lower() uri = uri.lower()
@ -731,6 +733,13 @@ def _get_link(uri, entry):
# We need to convert it to local timezone, feedparser always returns UTC # We need to convert it to local timezone, feedparser always returns UTC
age = age - datetime.timedelta(seconds=time.timezone) age = age - datetime.timedelta(seconds=time.timezone)
# Maybe the newznab also provided SxxExx info
try:
season = re.findall('\d+', entry['newznab']['season'])[0]
episode = re.findall('\d+', entry['newznab']['episode'])[0]
except:
season = episode = 0
if link and 'http' in link.lower(): if link and 'http' in link.lower():
try: try:
category = entry.cattext category = entry.cattext
@ -746,10 +755,10 @@ def _get_link(uri, entry):
except: except:
category = '' category = ''
return link, category, size, age return link, category, size, age, season, episode
else: else:
logging.warning(T('Empty RSS entry found (%s)'), link) logging.warning(T('Empty RSS entry found (%s)'), link)
return None, '', 0L, None return None, '', 0L, None, 0, 0
def special_rss_site(url): def special_rss_site(url):

Loading…
Cancel
Save