diff --git a/CHANGES.md b/CHANGES.md index d5c43e28..f6af4e15 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -179,6 +179,7 @@ * Change handle when a torrent provider goes down and its urls are cleared * Add handler for when rar files can not be opened during post processing * Fix join clean up +* Fix add custom torrent RSS ### 0.11.15 (2016-09-13 19:50:00 UTC) diff --git a/gui/slick/images/providers/xspeeds.png b/gui/slick/images/providers/xspeeds.png new file mode 100644 index 00000000..46cdec36 Binary files /dev/null and b/gui/slick/images/providers/xspeeds.png differ diff --git a/gui/slick/interfaces/default/config_providers.tmpl b/gui/slick/interfaces/default/config_providers.tmpl index 59f8e552..6d2b3290 100644 --- a/gui/slick/interfaces/default/config_providers.tmpl +++ b/gui/slick/interfaces/default/config_providers.tmpl @@ -110,7 +110,7 @@ /> $tip $cur_provider.name$state - #if $cur_provider.is_public_access()# + #if $cur_provider.is_public_access() and type($cur_provider).__name__ not in ['TorrentRssProvider'] (PA) #end if# #if not $cur_provider.supports_backlog#*#end if# @@ -531,7 +531,7 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam #end if - #if $hasattr($cur_torrent_provider, 'enable_recentsearch'): + #if $hasattr($cur_torrent_provider, 'enable_recentsearch') and $cur_torrent_provider.supports_backlog:
#end if + #if not $cur_torrent_provider.supports_backlog: +
+ The latest releases are the focus of this provider, no backlog searching +
+ #end if #end for @@ -731,6 +736,7 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam

eg. uid=xx;pass=yy

+

enter [ sg=0 ] if not required (a URL containing a key may not need cookies)

diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index f76873fb..6e49b393 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -1072,7 +1072,8 @@ def initialize(consoleLogging=True): torrent_prov.reject_m2ts = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_reject_m2ts', 0)) if hasattr(torrent_prov, 'enable_recentsearch'): torrent_prov.enable_recentsearch = bool(check_setting_int(CFG, prov_id_uc, - prov_id + '_enable_recentsearch', 1)) + prov_id + '_enable_recentsearch', 1)) or \ + not getattr(torrent_prov, 'supports_backlog', True) if hasattr(torrent_prov, 'enable_backlog'): torrent_prov.enable_backlog = bool(check_setting_int(CFG, prov_id_uc, prov_id + '_enable_backlog', 1)) if hasattr(torrent_prov, 'search_mode'): diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index 73daaa8b..8d3fea3b 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -19,6 +19,7 @@ import re from . import generic from sickbeard import logger, tvcache +from sickbeard.helpers import tryInt from sickbeard.exceptions import ex from sickbeard.rssfeeds import RSSFeeds from lib.bencode import bdecode @@ -28,32 +29,28 @@ class TorrentRssProvider(generic.TorrentProvider): def __init__(self, name, url, cookies='', search_mode='eponly', search_fallback=False, enable_recentsearch=False, enable_backlog=False): - generic.TorrentProvider.__init__(self, name) + self.enable_backlog = bool(tryInt(enable_backlog)) + generic.TorrentProvider.__init__(self, name, supports_backlog=self.enable_backlog, cache_update_freq=15) self.url = url.rstrip('/') + self.url_base = self.url self.cookies = cookies - self.enable_recentsearch = enable_recentsearch - self.enable_backlog = enable_backlog + self.enable_recentsearch = bool(tryInt(enable_recentsearch)) or not self.enable_backlog self.search_mode = search_mode - self.search_fallback = search_fallback + self.search_fallback = bool(tryInt(search_fallback)) self.feeder = RSSFeeds(self) - self.cache = TorrentRssCache(self) def image_name(self): return generic.GenericProvider.image_name(self, 'torrentrss') def config_str(self): - return '%s|%s|%s|%d|%s|%d|%d|%d' % (self.name or '', - self.url or '', - self.cookies or '', - self.enabled, - self.search_mode or '', - self.search_fallback, - self.enable_recentsearch, - self.enable_backlog) + + return '%s|%s|%s|%d|%s|%d|%d|%d' % ( + self.name or '', self.url or '', self.cookies or '', self.enabled, + self.search_mode or '', self.search_fallback, self.enable_recentsearch, self.enable_backlog) def _title_and_url(self, item): @@ -63,15 +60,13 @@ class TorrentRssProvider(generic.TorrentProvider): title = re.sub(r'\s+', '.', u'' + item.title) attempt_list = [lambda: item.torrent_magneturi, - lambda: item.enclosures[0].href, - lambda: item.link] for cur_attempt in attempt_list: try: url = cur_attempt() - except: + except (StandardError, Exception): continue if title and url: @@ -86,7 +81,7 @@ class TorrentRssProvider(generic.TorrentProvider): return success, err_msg try: - items = self.cache_data() + items = self._search_provider({'Validate': ['']}) for item in items: title, url = self._title_and_url(item) @@ -111,22 +106,14 @@ class TorrentRssProvider(generic.TorrentProvider): except Exception as e: return False, 'Error when trying to load RSS: ' + ex(e) - def cache_data(self): + def _search_provider(self, search_params, **kwargs): - logger.log(u'TorrentRssCache cache update URL: ' + self.url, logger.DEBUG) + result = [] + for mode in search_params.keys(): + data = self.feeder.get_feed(self.url) - data = self.feeder.get_feed(self.url) + result += (data and 'entries' in data) and data.entries or [] - return [] if not (data and 'entries' in data) else data.entries + self.log_result(mode, count=len(result), url=self.url) - -class TorrentRssCache(tvcache.TVCache): - - def __init__(self, provider): - tvcache.TVCache.__init__(self, provider) - - self.update_freq = 15 - - def _cache_data(self): - - return self.provider.cache_data() + return result diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 6094f257..d256c11e 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -482,7 +482,8 @@ class MainHandler(WebHandler): sql_results = list(set(sql_results)) # make a dict out of the sql results - sql_results = [dict(row) for row in sql_results] + sql_results = [dict(row) for row in sql_results + if Quality.splitCompositeStatus(helpers.tryInt(row['status']))[0] not in qualities] # multi dimension sort sorts = { @@ -4870,7 +4871,7 @@ class ConfigProviders(Config): tempProvider = rsstorrent.TorrentRssProvider(name, url, cookies) if tempProvider.get_id() in providerDict: - return json.dumps({'error': 'Exists as ' + providerDict[tempProvider.get_id()].name}) + return json.dumps({'error': 'A provider exists as [%s]' % providerDict[tempProvider.get_id()].name}) else: (succ, errMsg) = tempProvider.validate_feed() if succ: @@ -5040,14 +5041,15 @@ class ConfigProviders(Config): setattr(torrent_src, attr, key) attr = 'ratio' - if hasattr(torrent_src, '_seed_' + attr): + if hasattr(torrent_src, '_seed_' + attr) and src_id_prefix + attr in kwargs: setattr(torrent_src, '_seed_' + attr, kwargs.get(src_id_prefix + attr, '').strip() or None) for attr in [x for x in ['minseed', 'minleech'] if hasattr(torrent_src, x)]: setattr(torrent_src, attr, config.to_int(str(kwargs.get(src_id_prefix + attr)).strip())) for attr in [x for x in ['confirmed', 'freeleech', 'reject_m2ts', 'enable_recentsearch', - 'enable_backlog', 'search_fallback'] if hasattr(torrent_src, x)]: + 'enable_backlog', 'search_fallback'] + if hasattr(torrent_src, x) and src_id_prefix + attr in kwargs]: setattr(torrent_src, attr, config.checkbox_to_value(kwargs.get(src_id_prefix + attr))) attr = 'seed_time'