diff --git a/CHANGES.md b/CHANGES.md index 88753e95..1302c587 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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] diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index 4c881fcc..e7265454 100755 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -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)