From e42cdb5b4a5a92726e6b5ead1b8374390e564865 Mon Sep 17 00:00:00 2001 From: sammy2142 Date: Mon, 12 May 2014 11:31:44 +0100 Subject: [PATCH 1/6] Fixes Invalid ratio error when ratio is not set I would recommend undoing 7673cd5cc9d8e797a5b83cf956ede4eaae3deb7e for the time being as some of the client scripts have code dependent on the input being a string. --- sickbeard/clients/transmission.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sickbeard/clients/transmission.py b/sickbeard/clients/transmission.py index 82a87cd2..6f3e0e22 100644 --- a/sickbeard/clients/transmission.py +++ b/sickbeard/clients/transmission.py @@ -85,12 +85,12 @@ class TransmissionAPI(GenericClient): ratio = result.ratio elif sickbeard.TORRENT_RATIO: ratio = sickbeard.TORRENT_RATIO - - try: - float(ratio) - except ValueError: - logger.log(self.name + u': Invalid Ratio. "' + ratio + u'" is not a number', logger.ERROR) - return False + if ratio: + try: + float(ratio) + except ValueError: + logger.log(self.name + u': Invalid Ratio. "' + ratio + u'" is not a number', logger.ERROR) + return False torrent_id = self._get_torrent_hash(result) From e5a59afbd467a6139ee62e9271db111262857e8e Mon Sep 17 00:00:00 2001 From: DisasteR Date: Mon, 12 May 2014 16:09:55 +0200 Subject: [PATCH 2/6] Fix Renaming issue for not PROPER release generating two dot in filename --- sickbeard/tv.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index faae6e43..54c1b0ed 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1904,6 +1904,9 @@ class TVEpisode(object): result_name = result_name.replace('%rg', 'sickbeard') logger.log(u"Episode has no release name, replacing it with a generic one: " + result_name, logger.DEBUG) + if not replace_map['%RT']: + result_name = re.sub('([ _.-]*)%RT([ _.-]*)', r'\2', result_name) + # split off ep name part only name_groups = re.split(r'[\\/]', result_name) @@ -2138,4 +2141,4 @@ class TVEpisode(object): (self.season, self.episode) = sickbeard.scene_numbering.get_indexer_numbering(self.show.indexerid, self.show.indexer, self.scene_season, - self.scene_episode) \ No newline at end of file + self.scene_episode) From 331939a2298076a55f114edc75c41729538a8fd2 Mon Sep 17 00:00:00 2001 From: vzoltan Date: Mon, 12 May 2014 17:23:38 +0200 Subject: [PATCH 3/6] Update boxcar2.py This change adds a detailed push notification to Boxcar2 and also changes the sound of the notification. (tested, works) thanks Sorry for the duplication. --- sickbeard/notifiers/boxcar2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sickbeard/notifiers/boxcar2.py b/sickbeard/notifiers/boxcar2.py index b41a9d1f..5f3cec4d 100755 --- a/sickbeard/notifiers/boxcar2.py +++ b/sickbeard/notifiers/boxcar2.py @@ -52,9 +52,9 @@ class Boxcar2Notifier: data = urllib.urlencode({ 'user_credentials': accesstoken, - 'notification[title]': "SickRage : " + title, + 'notification[title]': "SickRage : " + title + ' ' + msg, 'notification[long_message]': msg, - 'notification[sound]': "bird-1" + 'notification[sound]': "success" }) # send the request to boxcar2 From 220b139bcc11dc9d957b26430831d68d738ca95e Mon Sep 17 00:00:00 2001 From: iron8core Date: Tue, 13 May 2014 13:19:03 +0200 Subject: [PATCH 4/6] Add forgotten 'self' argument to _isSection --- sickbeard/providers/scc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sickbeard/providers/scc.py b/sickbeard/providers/scc.py index 733418dc..5f907489 100644 --- a/sickbeard/providers/scc.py +++ b/sickbeard/providers/scc.py @@ -142,7 +142,7 @@ class SCCProvider(generic.TorrentProvider): return [search_string] - def _isSection(section, text): + def _isSection(self, section, text): title = '.+? \| %s' % section if re.search(title, text, re.IGNORECASE): return True From dd16da1a5fc65a3efe8efd9eddad2f0371967623 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 13 May 2014 08:44:31 -0700 Subject: [PATCH 5/6] Fixed cache issues. Fixed air-by-date issues --- sickbeard/__init__.py | 16 +++++++++++++++- sickbeard/helpers.py | 20 ++++++++++++-------- sickbeard/name_parser/parser.py | 5 ++++- sickbeard/tvcache.py | 21 +++++++-------------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index d981bed6..b18c037f 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -50,6 +50,8 @@ from sickbeard.databases import mainDB, cache_db, failed_db from lib.configobj import ConfigObj +import xml.etree.ElementTree as ElementTree + invoked_command = None PID = None @@ -135,6 +137,7 @@ ROOT_DIRS = None UPDATE_SHOWS_ON_START = None SORT_ARTICLE = None DEBUG = False +CLEAR_CACHE = None USE_LISTVIEW = None METADATA_XBMC = None @@ -521,7 +524,7 @@ def initialize(consoleLogging=True): USE_SYNOLOGYNOTIFIER, SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH, SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD, SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD, \ USE_EMAIL, EMAIL_HOST, EMAIL_PORT, EMAIL_TLS, EMAIL_USER, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_NOTIFY_ONSNATCH, EMAIL_NOTIFY_ONDOWNLOAD, EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD, EMAIL_LIST, \ USE_LISTVIEW, METADATA_XBMC, METADATA_XBMC_12PLUS, METADATA_MEDIABROWSER, METADATA_PS3, metadata_provider_dict, \ - NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, \ + NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, CLEAR_CACHE, \ GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, \ METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \ ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \ @@ -1123,6 +1126,15 @@ def initialize(consoleLogging=True): showList = [] loadingShowList = {} + url = 'http://raw.github.com/echel0n/sickrage-init/master/settings.ini' + clear_cache = ElementTree.XML(helpers.getURL(url)).find('cache/clear').text + CLEAR_CACHE = check_setting_str(CFG, 'General', 'clear_cache', '') + if CLEAR_CACHE != clear_cache: + for curProvider in [x for x in providers.sortedProviderList() if x.isActive()]: + curProvider.cache._clearCache() + CLEAR_CACHE = clear_cache + save_config() + __INITIALIZED__ = True return True @@ -1442,6 +1454,8 @@ def save_config(): new_config['General']['ignore_words'] = IGNORE_WORDS new_config['General']['calendar_unprotected'] = int(CALENDAR_UNPROTECTED) + new_config['General']['clear_cache'] = CLEAR_CACHE + new_config['Blackhole'] = {} new_config['Blackhole']['nzb_dir'] = NZB_DIR new_config['Blackhole']['torrent_dir'] = TORRENT_DIR diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 5726e90c..751fa59a 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -212,10 +212,11 @@ def getURL(url, post_data=None, headers=None, params=None, timeout=30, json=Fals logger.log(u"Connection timed out " + str(e.message) + " while loading URL " + url, logger.WARNING) return None - if json: - return r.json() if r.ok else None + if r.ok: + if json: + return r.json() - return r.content if r.ok else None + return r.content def _remove_file_failed(file): @@ -284,7 +285,7 @@ def makeDir(path): return True -def searchDBForShow(regShowName): +def searchDBForShow(regShowName, log=False): showNames = [re.sub('[. -]', ' ', regShowName)] myDB = db.DBConnection() @@ -303,17 +304,20 @@ def searchDBForShow(regShowName): # if we didn't get exactly one result then try again with the year stripped off if possible match = re.match(yearRegex, showName) if match and match.group(1): - logger.log(u"Unable to match original name but trying to manually strip and specify show year", - logger.DEBUG) + if log: + logger.log(u"Unable to match original name but trying to manually strip and specify show year", + logger.DEBUG) sqlResults = myDB.select( "SELECT * FROM tv_shows WHERE (show_name LIKE ?) AND startyear = ?", [match.group(1) + '%', match.group(3)]) if len(sqlResults) == 0: - logger.log(u"Unable to match a record in the DB for " + showName, logger.DEBUG) + if log: + logger.log(u"Unable to match a record in the DB for " + showName, logger.DEBUG) continue elif len(sqlResults) > 1: - logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name", logger.DEBUG) + if log: + logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name", logger.DEBUG) continue else: return (int(sqlResults[0]["indexer_id"]), sqlResults[0]["show_name"]) diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index d2dae022..aacad9f5 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -377,7 +377,10 @@ class ParseResult(object): if self.season_number == None: return self # can't work without a season if len(self.episode_numbers) == 0: return self # need at least one episode - self.show = helpers.get_show_by_name(self.series_name) + showResult = helpers.searchDBForShow(self.series_name) + if showResult: + self.show = helpers.findCertainShow(sickbeard.showList, int(showResult[0])) + if not self.show: return self diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index f59d03ff..6f90739f 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -232,7 +232,7 @@ class TVCache(): # if we don't have complete info then parse the filename to get it try: myParser = NameParser() - parse_result = myParser.parse(name) + parse_result = myParser.parse(name).convert() except InvalidNameException: logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG) return None @@ -255,13 +255,6 @@ class TVCache(): if showResult: indexerid = int(showResult[0]) - # if not indexerid: - # for curShow in sickbeard.showList: - # if curShow.name == parse_result.series_name: - # if show_name_helpers.isGoodResult(name, curShow, False): - # indexerid = int(curShow.indexerid) - # break - showObj = None if indexerid: showObj = helpers.findCertainShow(sickbeard.showList, indexerid) @@ -327,14 +320,14 @@ class TVCache(): def findNeededEpisodes(self, epObj=None, manualSearch=False): neededEps = {} - myDB = self._getDB() + cacheDB = self._getDB() if not epObj: - sqlResults = myDB.select("SELECT * FROM [" + self.providerID + "]") + sqlResults = cacheDB.select("SELECT * FROM [" + self.providerID + "]") else: - sqlResults = myDB.select( + sqlResults = cacheDB.select( "SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?", - [epObj.show.indexerid, epObj.scene_season, "%|" + str(epObj.scene_episode) + "|%"]) + [epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"]) # for each cache entry for curResult in sqlResults: @@ -386,9 +379,9 @@ class TVCache(): # add it to the list if epObj not in neededEps: - neededEps[epObj] = [result] + neededEps[epObj.episode] = [result] else: - neededEps[epObj].append(result) + neededEps[epObj.episode].append(result) return neededEps From cd77da5b601e642eee7529e2bddca35ca751c1f7 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 13 May 2014 08:45:29 -0700 Subject: [PATCH 6/6] Small typo fix --- sickbeard/__init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index b18c037f..73f2066a 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -1126,14 +1126,16 @@ def initialize(consoleLogging=True): showList = [] loadingShowList = {} - url = 'http://raw.github.com/echel0n/sickrage-init/master/settings.ini' - clear_cache = ElementTree.XML(helpers.getURL(url)).find('cache/clear').text - CLEAR_CACHE = check_setting_str(CFG, 'General', 'clear_cache', '') - if CLEAR_CACHE != clear_cache: - for curProvider in [x for x in providers.sortedProviderList() if x.isActive()]: - curProvider.cache._clearCache() - CLEAR_CACHE = clear_cache - save_config() + try: + url = 'http://raw.github.com/echel0n/sickrage-init/master/settings.ini' + clear_cache = ElementTree.XML(helpers.getURL(url)).find('cache/clear').text + CLEAR_CACHE = check_setting_str(CFG, 'General', 'clear_cache', '') + if CLEAR_CACHE != clear_cache: + for curProvider in [x for x in providers.sortedProviderList() if x.isActive()]: + curProvider.cache._clearCache() + CLEAR_CACHE = clear_cache + save_config() + except:pass __INITIALIZED__ = True return True