Merge pull request #849 from JackDandy/feature/ChangeNewnabTitleUrlParsing

Change recent search to use centralised title and URL parser for newz…
This commit is contained in:
JackDandy 2016-12-28 03:15:10 +00:00 committed by GitHub
commit 9d27f6a9cb
2 changed files with 6 additions and 11 deletions

View file

@ -1,6 +1,7 @@
### 0.13.0 (2016-xx-xx xx:xx:xx UTC)
* Change don't fetch caps for disabled nzb providers
* Change recent search to use centralised title and URL parser for newznab
[develop changelog]

View file

@ -414,14 +414,13 @@ class NewznabProvider(generic.NZBProvider):
def _title_and_url(self, item):
title, url = None, None
try:
title = item.findtext('title')
url = item.findtext('link')
title = ('%s' % item.findtext('title')).strip()
for pattern, repl in ((r'\s+', '.'), (r'(?i)-Obfuscated$', '')):
title = re.sub(pattern, repl, title)
url = str(item.findtext('link')).replace('&', '&')
except (StandardError, Exception):
pass
title = title and re.sub(r'\s+', '.', '%s' % title)
url = url and str(url).replace('&', '&')
return title, url
def get_show(self, item, **kwargs):
@ -859,19 +858,14 @@ class NewznabCache(tvcache.TVCache):
# overwrite method with that parses the rageid from the newznab feed
def _parseItem(self, ns, item):
title = item.findtext('title')
url = item.findtext('link')
title, url = self._title_and_url(item)
ids = self.parse_ids(item, ns)
self._checkItemAuth(title, url)
if not title or not url:
logger.log('The data returned from the %s feed is incomplete, this result is unusable'
% self.provider.name, logger.DEBUG)
return None
url = self._translateLinkURL(url)
logger.log('Attempting to add item from RSS to cache: %s' % title, logger.DEBUG)
return self.add_cache_entry(title, url, id_dict=ids)