From d37a992508507998a37a2b1092855133fafc63b8 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 22 May 2014 22:36:48 -0700 Subject: [PATCH 1/2] Fixes issue with trailing slash being appened to end of url when adding custom RSS torrent provider. --- sickbeard/config.py | 29 +++++++++++++++++++---------- sickbeard/providers/rsstorrent.py | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/sickbeard/config.py b/sickbeard/config.py index d2eb82c3..45ad4dcb 100644 --- a/sickbeard/config.py +++ b/sickbeard/config.py @@ -20,9 +20,10 @@ import cherrypy import os.path import datetime import re -import time +import urlparse import sickbeard +from sickbeard import encodingKludge as ek from sickbeard import helpers from sickbeard import logger from sickbeard import naming @@ -274,22 +275,30 @@ def clean_hosts(hosts, default_port=None): def clean_url(url): """ - Returns an url starting with http:// or https:// and ending with / + Returns an cleaned url starting with a scheme and folder with trailing / or an empty string """ - if url: + if url and url.strip(): - if not re.match(r'(https?|scgi)://.*', url): - url = 'http://' + url + url = url.strip() - if not url.endswith('/'): - url = url + '/' + if '://' not in url: + url = '//' + url + + scheme, netloc, path, query, fragment = urlparse.urlsplit(url, 'http') + + if not path.endswith('/'): + basename, ext = ek.ek(os.path.splitext, ek.ek(os.path.basename, path)) # @UnusedVariable + if not ext: + path = path + '/' + + cleaned_url = urlparse.urlunsplit((scheme, netloc, path, query, fragment)) else: - url = '' + cleaned_url = '' - return url + return cleaned_url def to_int(val, default=0): @@ -376,7 +385,7 @@ def check_setting_str(config, cfg_name, item_name, def_val, log=True): config[cfg_name][item_name] = helpers.encrypt(my_val, encryption_version) if log: - logger.log(item_name + " -> " + my_val, logger.DEBUG) + logger.log(item_name + " -> " + str(my_val), logger.DEBUG) else: logger.log(item_name + " -> ******", logger.DEBUG) diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index ccf44e13..b319acad 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -38,7 +38,7 @@ class TorrentRssProvider(generic.TorrentProvider): def __init__(self, name, url, search_mode='eponly', search_fallback=False, backlog_only=False): generic.TorrentProvider.__init__(self, name) self.cache = TorrentRssCache(self) - #self.url = re.sub('\/$', '', url) + self.url = re.sub('\/$', '', url) self.url = url self.enabled = True self.supportsBacklog = False From 753be6409031002b7f0eca289461836a6ca0950b Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 22 May 2014 22:43:53 -0700 Subject: [PATCH 2/2] Fixes issue of missing ui notification to let you know that there was no update needed when forcing a version check. --- sickbeard/versionChecker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index 41a03197..a79a80d7 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -120,7 +120,7 @@ class CheckVersion(): if not sickbeard.AUTO_UPDATE: logger.log(u"No update needed") - if force and not sickbeard.AUTO_UPDATE: + if force: ui.notifications.message('No update needed') return False