diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 6db9f27f..bd6ef60b 100755 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -397,20 +397,36 @@ -
+
- ComicRN script cannot be used with this enabled + ComicRN script cannot be used with this enabled & required SAB version > 0.8.0 +
+
+
+ -

+
+ <% + if mylar.CONFIG.SAB_VERSION is not None: + sabv = 'last tested version: %s' % mylar.CONFIG.SAB_VERSION + else: + sabv = '' + %> + ${sabv} +
@@ -1949,7 +1965,9 @@ function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; - + function numberWithDecimals(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."); + }; $("#test_32p").click(function(){ var imagechk = document.getElementById("test32p_statusicon"); $.get('test_32p', @@ -1990,8 +2008,26 @@ alert(data.error); return; } - $('#sabstatus').val(data); - $('#ajaxMsg').html("
"+data+"
"); + var obj = JSON.parse(data); + var versionsab = obj['version']; + vsab = numberWithDecimals(versionsab); + alert(vsab); + $('#sabstatus').val(obj['status']); + $('#sabversion span').text('SABnzbd version: '+versionsab); + if ( vsab < "0.8.0" ){ + scdh = document.getElementById("sab_cdh"); + scdh.style.display = "none"; + nocdh = document.getElementById("sab_nocdh"); + nocdh.style.display = "unset"; + scdh_line = document.getElementById("sab_client_post_processing"); + scdh_line.value = 0; + } else { + scdh = document.getElementById("sab_cdh"); + scdh.style.display = "unset"; + nocdh = document.getElementById("sab_nocdh"); + nocdh.style.display = "none"; + } + $('#ajaxMsg').html("
"+obj['status']+"
"); if ( data.indexOf("Successfully") > -1){ imagechk.src = ""; imagechk.src = "interfaces/default/images/success.png"; diff --git a/mylar/PostProcessor.py b/mylar/PostProcessor.py index 645316e9..0e727b5e 100755 --- a/mylar/PostProcessor.py +++ b/mylar/PostProcessor.py @@ -350,15 +350,18 @@ class PostProcessor(object): logger.fdebug(module + ' nzb name: ' + self.nzb_name) logger.fdebug(module + ' nzb folder: ' + self.nzb_folder) if self.ddl is False: - if mylar.USE_SABNZBD==0: - logger.fdebug(module + ' Not using SABnzbd') - elif mylar.USE_SABNZBD != 0 and self.nzb_name == 'Manual Run': - logger.fdebug(module + ' Not using SABnzbd : Manual Run') - else: - # if the SAB Directory option is enabled, let's use that folder name and append the jobname. - if all([mylar.CONFIG.SAB_TO_MYLAR, mylar.CONFIG.SAB_DIRECTORY is not None, mylar.CONFIG.SAB_DIRECTORY != 'None']): - self.nzb_folder = os.path.join(mylar.CONFIG.SAB_DIRECTORY, self.nzb_name).encode(mylar.SYS_ENCODING) - logger.fdebug(module + ' SABnzbd Download folder option enabled. Directory set to : ' + self.nzb_folder) + if mylar.USE_SABNZBD==1: + if self.nzb_name != 'Manual Run': + logger.fdebug(module + ' Using SABnzbd') + logger.fdebug(module + ' NZB name as passed from NZBGet: ' + self.nzb_name) + + if self.nzb_name == 'Manual Run': + logger.fdebug(module + ' Manual Run Post-Processing enabled.') + else: + # if the SAB Directory option is enabled, let's use that folder name and append the jobname. + if all([mylar.CONFIG.SAB_TO_MYLAR, mylar.CONFIG.SAB_DIRECTORY is not None, mylar.CONFIG.SAB_DIRECTORY != 'None']): + self.nzb_folder = os.path.join(mylar.CONFIG.SAB_DIRECTORY, self.nzb_name).encode(mylar.SYS_ENCODING) + logger.fdebug(module + ' SABnzbd Download folder option enabled. Directory set to : ' + self.nzb_folder) if mylar.USE_NZBGET==1: if self.nzb_name != 'Manual Run': @@ -471,8 +474,50 @@ class PostProcessor(object): if any([self.issueid is not None, self.comicid is not None]): comicseries = myDB.select('SELECT * FROM comics WHERE ComicID=?', [self.comicid]) else: - tmpsql = "SELECT * FROM comics WHERE DynamicComicName IN ({seq}) COLLATE NOCASE".format(seq=','.join('?' * len(loopchk))) - comicseries = myDB.select(tmpsql, tuple(loopchk)) + if fl['issueid'] is not None: + logger.info('issueid detected in filename: %s' % fl['issueid']) + csi = myDB.selectone('SELECT i.ComicID, i.IssueID, i.Issue_Number, c.ComicName FROM comics as c JOIN issues as i ON c.ComicID = i.ComicID WHERE i.IssueID=?', [fl['issueid']]).fetchone() + if csi is None: + csi = myDB.selectone('SELECT i.ComicID as comicid, i.IssueID, i.Issue_Number, a.ReleaseComicName, c.ComicName FROM comics as c JOIN annuals as a ON c.ComicID = a.ComicID WHERE a.IssueID=?', [fl['issueid']]).fetchone() + if csi is not None: + annchk = 'yes' + else: + continue + else: + annchk = 'no' + if fl['sub']: + logger.fdebug('%s[SUB: %s][CLOCATION: %s]' % (module, fl['sub'], fl['comiclocation'])) + clocation = os.path.join(fl['comiclocation'], fl['sub'], helpers.conversion(fl['comicfilename'])) + else: + logger.fdebug('%s[CLOCATION] %s' % (module, fl['comiclocation'])) + clocation = os.path.join(fl['comiclocation'],helpers.conversion(fl['comicfilename'])) + annualtype = None + if annchk == 'yes': + if 'Annual' in csi['ReleaseComicName']: + annualtype = 'Annual' + elif 'Special' in csi['ReleaseComicName']: + annualtype = 'Special' + else: + if 'Annual' in csi['ComicName']: + annualtype = 'Annual' + elif 'Special' in csi['ComicName']: + annualtype = 'Special' + manual_list.append({"ComicLocation": clocation, + "ComicID": csi['ComicID'], + "IssueID": csi['IssueID'], + "IssueNumber": csi['Issue_Number'], + "AnnualType": annualtype, + "ComicName": csi['ComicName'], + "Series": fl['series_name'], + "AltSeries": fl['alt_series'], + "One-Off": False, + "ForcedMatch": True}) + logger.info('manual_list: %s' % manual_list) + break + + else: + tmpsql = "SELECT * FROM comics WHERE DynamicComicName IN ({seq}) COLLATE NOCASE".format(seq=','.join('?' * len(loopchk))) + comicseries = myDB.select(tmpsql, tuple(loopchk)) if not comicseries or orig_seriesname != mod_seriesname: if all(['special' in orig_seriesname.lower(), mylar.CONFIG.ANNUALS_ON, orig_seriesname != mod_seriesname]): @@ -787,7 +832,8 @@ class PostProcessor(object): "ComicName": cs['ComicName'], "Series": watchmatch['series_name'], "AltSeries": watchmatch['alt_series'], - "One-Off": False}) + "One-Off": False, + "ForcedMatch": False}) break else: logger.fdebug(module + '[NON-MATCH: ' + cs['ComicName'] + '-' + cs['ComicID'] + '] Incorrect series - not populating..continuing post-processing') @@ -894,7 +940,7 @@ class PostProcessor(object): "ComicVersion": 'v' + str(av['SeriesYear']), "Publisher": av['IssuePublisher'], "Total": av['TotalIssues'], # this will return the total issues in the arc (not needed for this) - "ComicID": av['ComicID'], + "Type": av['Type'], "IsArc": True} }) @@ -923,28 +969,50 @@ class PostProcessor(object): if arcmatch['process_status'] == 'fail': nm+=1 else: - temploc= arcmatch['justthedigits'].replace('_', ' ') - temploc = re.sub('[\#\']', '', temploc) - if helpers.issuedigits(temploc) != helpers.issuedigits(v[i]['ArcValues']['IssueNumber']): + try: + if v[i]['ArcValues']['Type'] == 'TPB' and v[i]['ArcValues']['Total'] > 1: + if watchmatch['series_volume'] is not None: + just_the_digits = re.sub('[^0-9]', '', arcmatch['series_volume']).strip() + else: + just_the_digits = re.sub('[^0-9]', '', arcmatch['justthedigits']).strip() + else: + just_the_digits = arcmatch['justthedigits'] + except Exception as e: + logger.warn('[Exception: %s] Unable to properly match up/retrieve issue number (or volume) for this [CS: %s] [WATCHMATCH: %s]' % (e, v[i]['ArcValues'], v[i]['WatchValues'])) + nm+=1 + continue + + if just_the_digits is not None: + temploc= just_the_digits.replace('_', ' ') + temploc = re.sub('[\#\']', '', temploc) + logger.fdebug('temploc: %s' % temploc) + else: + temploc = None + + if temploc is not None and helpers.issuedigits(temploc) != helpers.issuedigits(v[i]['ArcValues']['IssueNumber']): #logger.fdebug('issues dont match. Skipping') i+=1 continue - if 'annual' in temploc.lower(): - biannchk = re.sub('-', '', temploc.lower()).strip() - if 'biannual' in biannchk: - logger.fdebug(module + ' Bi-Annual detected.') - fcdigit = helpers.issuedigits(re.sub('biannual', '', str(biannchk)).strip()) - else: - fcdigit = helpers.issuedigits(re.sub('annual', '', str(temploc.lower())).strip()) - logger.fdebug(module + ' Annual detected [' + str(fcdigit) +']. ComicID assigned as ' + str(v[i]['WatchValues']['ComicID'])) - annchk = "yes" - issuechk = myDB.selectone("SELECT * from storyarcs WHERE ComicID=? AND Int_IssueNumber=?", [v[i]['WatchValues']['ComicID'], fcdigit]).fetchone() else: - fcdigit = helpers.issuedigits(temploc) - issuechk = myDB.selectone("SELECT * from storyarcs WHERE ComicID=? AND Int_IssueNumber=?", [v[i]['WatchValues']['ComicID'], fcdigit]).fetchone() + if 'annual' in temploc.lower(): + biannchk = re.sub('-', '', temploc.lower()).strip() + if 'biannual' in biannchk: + logger.fdebug(module + ' Bi-Annual detected.') + fcdigit = helpers.issuedigits(re.sub('biannual', '', str(biannchk)).strip()) + else: + fcdigit = helpers.issuedigits(re.sub('annual', '', str(temploc.lower())).strip()) + logger.fdebug(module + ' Annual detected [' + str(fcdigit) +']. ComicID assigned as ' + str(v[i]['WatchValues']['ComicID'])) + annchk = "yes" + issuechk = myDB.selectone("SELECT * from storyarcs WHERE ComicID=? AND Int_IssueNumber=?", [v[i]['WatchValues']['ComicID'], fcdigit]).fetchone() + else: + fcdigit = helpers.issuedigits(temploc) + issuechk = myDB.selectone("SELECT * from storyarcs WHERE ComicID=? AND Int_IssueNumber=?", [v[i]['WatchValues']['ComicID'], fcdigit]).fetchone() if issuechk is None: - logger.fdebug(module + ' No corresponding issue # found for ' + str(v[i]['WatchValues']['ComicID'])) + try: + logger.fdebug(module + ' No corresponding issue # found for ' + str(v[i]['WatchValues']['ComicID'])) + except: + continue else: datematch = "True" if len(arcmatch) >= 1 and arcmatch['issue_year'] is not None: @@ -1037,7 +1105,7 @@ class PostProcessor(object): if all(['0-Day Week' in self.nzb_name, mylar.CONFIG.PACK_0DAY_WATCHLIST_ONLY is True]): pass else: - oneofflist = myDB.select("select s.Issue_Number, s.ComicName, s.IssueID, s.ComicID, s.Provider, w.PUBLISHER, w.weeknumber, w.year from snatched as s inner join nzblog as n on s.IssueID = n.IssueID inner join weekly as w on s.IssueID = w.IssueID WHERE n.OneOff = 1;") #(s.Provider ='32P' or s.Provider='WWT' or s.Provider='DEM') AND n.OneOff = 1;") + oneofflist = myDB.select("select s.Issue_Number, s.ComicName, s.IssueID, s.ComicID, s.Provider, w.format, w.PUBLISHER, w.weeknumber, w.year from snatched as s inner join nzblog as n on s.IssueID = n.IssueID inner join weekly as w on s.IssueID = w.IssueID WHERE n.OneOff = 1;") #(s.Provider ='32P' or s.Provider='WWT' or s.Provider='DEM') AND n.OneOff = 1;") #oneofflist = myDB.select("select s.Issue_Number, s.ComicName, s.IssueID, s.ComicID, s.Provider, w.PUBLISHER, w.weeknumber, w.year from snatched as s inner join nzblog as n on s.IssueID = n.IssueID and s.Hash is not NULL inner join weekly as w on s.IssueID = w.IssueID WHERE n.OneOff = 1;") #(s.Provider ='32P' or s.Provider='WWT' or s.Provider='DEM') AND n.OneOff = 1;") if not oneofflist: pass #continue @@ -1057,6 +1125,7 @@ class PostProcessor(object): "ComicVersion": None, "Publisher": ofl['PUBLISHER'], "Total": None, + "Type": ofl['format'], "ComicID": ofl['ComicID'], "IsArc": False}}) @@ -1074,23 +1143,41 @@ class PostProcessor(object): nm+=1 continue else: - temploc= watchmatch['justthedigits'].replace('_', ' ') - temploc = re.sub('[\#\']', '', temploc) + try: + if ofv['WatchValues']['Type'] is not None and ofv['WatchValues']['Total'] > 1: + if watchmatch['series_volume'] is not None: + just_the_digits = re.sub('[^0-9]', '', watchmatch['series_volume']).strip() + else: + just_the_digits = re.sub('[^0-9]', '', watchmatch['justthedigits']).strip() + else: + just_the_digits = watchmatch['justthedigits'] + except Exception as e: + logger.warn('[Exception: %s] Unable to properly match up/retrieve issue number (or volume) for this [CS: %s] [WATCHMATCH: %s]' % (e, cs, watchmatch)) + nm+=1 + continue + + if just_the_digits is not None: + temploc= just_the_digits.replace('_', ' ') + temploc = re.sub('[\#\']', '', temploc) + logger.fdebug('temploc: %s' % temploc) + else: + temploc = None logger.info('watchmatch: %s' % watchmatch) - if 'annual' in temploc.lower(): - biannchk = re.sub('-', '', temploc.lower()).strip() - if 'biannual' in biannchk: - logger.fdebug(module + ' Bi-Annual detected.') - fcdigit = helpers.issuedigits(re.sub('biannual', '', str(biannchk)).strip()) + if temploc is not None: + if 'annual' in temploc.lower(): + biannchk = re.sub('-', '', temploc.lower()).strip() + if 'biannual' in biannchk: + logger.fdebug(module + ' Bi-Annual detected.') + fcdigit = helpers.issuedigits(re.sub('biannual', '', str(biannchk)).strip()) + else: + fcdigit = helpers.issuedigits(re.sub('annual', '', str(temploc.lower())).strip()) + logger.fdebug(module + ' Annual detected [' + str(fcdigit) +']. ComicID assigned as ' + str(ofv['ComicID'])) + annchk = "yes" else: - fcdigit = helpers.issuedigits(re.sub('annual', '', str(temploc.lower())).strip()) - logger.fdebug(module + ' Annual detected [' + str(fcdigit) +']. ComicID assigned as ' + str(ofv['ComicID'])) - annchk = "yes" - else: - fcdigit = helpers.issuedigits(temploc) + fcdigit = helpers.issuedigits(temploc) - if fcdigit == helpers.issuedigits(ofv['Issue_Number']): + if temploc is not None and fcdigit == helpers.issuedigits(ofv['Issue_Number']) or all([temploc is None, helpers.issuedigits(ofv['Issue_Number']) == '1']): if watchmatch['sub']: clocation = os.path.join(watchmatch['comiclocation'], watchmatch['sub'], helpers.conversion(watchmatch['comicfilename'])) else: @@ -2260,6 +2347,16 @@ class PostProcessor(object): nfilename = nfilename.replace(' ', mylar.CONFIG.REPLACE_CHAR) nfilename = re.sub('[\,\:\?\"\']', '', nfilename) nfilename = re.sub('[\/\*]', '-', nfilename) + if ml['ForcedMatch'] is True: + xyb = nfilename.find('[__') + if xyb != -1: + yyb = nfilename.find('__]', xyb) + if yyb != -1: + rem_issueid = nfilename[xyb+3:yyb] + logger.fdebug('issueid: %s' % rem_issueid) + nfilename = '%s %s'.strip() % (nfilename[:xyb], nfilename[yyb+3:]) + logger.fdebug('issueid information [%s] removed successsfully: %s' % (rem_issueid, nfilename)) + self._log("New Filename: " + nfilename) logger.fdebug(module + ' New Filename: ' + nfilename) diff --git a/mylar/config.py b/mylar/config.py index 10b5eb8d..8f9d009c 100644 --- a/mylar/config.py +++ b/mylar/config.py @@ -208,6 +208,7 @@ _CONFIG_DEFINITIONS = OrderedDict({ 'SAB_PRIORITY': (str, 'SABnzbd', "Default"), 'SAB_TO_MYLAR': (bool, 'SABnzbd', False), 'SAB_DIRECTORY': (str, 'SABnzbd', None), + 'SAB_VERSION': (str, 'SABnzbd', None), 'SAB_CLIENT_POST_PROCESSING': (bool, 'SABnzbd', False), #0/False: ComicRN.py, #1/True: Completed Download Handling 'NZBGET_HOST': (str, 'NZBGet', None), @@ -795,7 +796,6 @@ class Config(object): mylar.RSS_STATUS = 'Waiting' elif self.ENABLE_RSS is False and mylar.RSS_STATUS == 'Waiting': mylar.RSS_STATUS = 'Paused' - logger.info('self.enable_rss is %s [%s]' % (self.ENABLE_RSS, mylar.RSS_STATUS)) if not helpers.is_number(self.CHMOD_DIR): logger.fdebug("CHMOD Directory value is not a valid numeric - please correct. Defaulting to 0777") @@ -875,6 +875,12 @@ class Config(object): elif self.SAB_PRIORITY == "4": self.SAB_PRIORITY = "Paused" else: self.SAB_PRIORITY = "Default" + if self.SAB_VERSION is not None: + config.set('SABnzbd', 'sab_version', self.SAB_VERSION) + if int(re.sub("[^0-9]", '', self.SAB_VERSION).strip()) < int(re.sub("[^0-9]", '', '0.8.0').strip()) and self.SAB_CLIENT_POST_PROCESSING is True: + logger.warn('Your SABnzbd client is less than 0.8.0, and does not support Completed Download Handling which is enabled. Disabling CDH.') + self.SAB_CLIENT_POST_PROCESSING = False + mylar.USE_WATCHDIR = False mylar.USE_UTORRENT = False mylar.USE_RTORRENT = False diff --git a/mylar/filechecker.py b/mylar/filechecker.py index 88f00962..99c477d9 100755 --- a/mylar/filechecker.py +++ b/mylar/filechecker.py @@ -50,7 +50,8 @@ class FileChecker(object): self.watchcomic = re.sub('\?', '', watchcomic).strip() #strip the ? sepearte since it affects the regex. self.watchcomic = re.sub(u'\u2014', ' - ', watchcomic).strip() #replace the \u2014 with a normal - because this world is f'd up enough to have something like that. self.watchcomic = re.sub(u'\u2013', ' - ', watchcomic).strip() #replace the \u2013 with a normal - because again, people are dumb. - self.watchcomic = unicodedata.normalize('NFKD', self.watchcomic).encode('ASCII', 'ignore') + if type(self.watchcomic) != str: + self.watchcomic = unicodedata.normalize('NFKD', self.watchcomic).encode('ASCII', 'ignore') else: self.watchcomic = None @@ -107,7 +108,6 @@ class FileChecker(object): self.AS_Alt = AS_Alternates['AS_Alt'] self.AS_Tuple = AS_Alternates['AS_Tuple'] - def listFiles(self): comiclist = [] watchmatch = {} @@ -122,6 +122,7 @@ class FileChecker(object): 'comiclocation': runresults['comiclocation'], 'series_name': runresults['series_name'], 'series_name_decoded': runresults['series_name_decoded'], + 'issueid': runresults['issueid'], 'dynamic_name': runresults['dynamic_name'], 'series_volume': runresults['series_volume'], 'alt_series': runresults['alt_series'], @@ -159,6 +160,7 @@ class FileChecker(object): 'comiclocation': runresults['comiclocation'], 'series_name': runresults['series_name'], 'series_name_decoded': runresults['series_name_decoded'], + 'issueid': runresults['issueid'], 'alt_series': runresults['alt_series'], 'alt_issue': runresults['alt_issue'], 'dynamic_name': runresults['dynamic_name'], @@ -179,6 +181,7 @@ class FileChecker(object): 'IssueYear': runresults['issue_year'], 'JusttheDigits': runresults['justthedigits'], 'AnnualComicID': runresults['annual_comicid'], + 'issueid': runresults['issueid'], 'scangroup': runresults['scangroup'] }) comiccnt +=1 @@ -194,6 +197,7 @@ class FileChecker(object): 'alt_issue': runresults['alt_issue'], 'issue_year': runresults['issue_year'], 'issue_number': runresults['issue_number'], + 'issueid': runresults['issueid'], 'scangroup': runresults['scangroup'] }) @@ -283,6 +287,16 @@ class FileChecker(object): modfilename = modfilename.replace('()','').strip() + issueid = None + x = modfilename.find('[__') + if x != -1: + y = modfilename.find('__]', x) + if y != -1: + issueid = modfilename[x+3:y] + logger.fdebug('issueid: %s' % issueid) + modfilename = '%s %s'.strip() % (modfilename[:x], modfilename[y+3:]) + logger.fdebug('issueid %s removed successsfully: %s' % (issueid, modfilename)) + #here we take a snapshot of the current modfilename, the intent is that we will remove characters that match #as we discover them - namely volume, issue #, years, etc #the remaining strings should be the series title and/or issue title if present (has to be detected properly) @@ -1059,6 +1073,7 @@ class FileChecker(object): 'comiclocation': self.dir, 'series_name': series_name, 'series_name_decoded': series_name_decoded, + 'issueid': issueid, 'alt_series': alt_series, 'alt_issue': alt_issue, 'dynamic_name': dreplace, @@ -1078,6 +1093,7 @@ class FileChecker(object): 'comiclocation': self.dir, 'series_name': series_name, 'series_name_decoded': series_name_decoded, + 'issueid': issueid, 'alt_series': alt_series, 'alt_issue': alt_issue, 'dynamic_name': self.dynamic_replace(series_name)['mod_seriesname'], @@ -1094,6 +1110,7 @@ class FileChecker(object): 'comiclocation': self.dir, 'series_name': series_name, 'series_name_decoded': series_name_decoded, + 'issueid': issueid, 'alt_series': alt_series, 'alt_issue': alt_issue, 'series_volume': issue_volume, @@ -1259,6 +1276,7 @@ class FileChecker(object): 'alt_series': series_info['alt_series'], 'alt_issue': series_info['alt_issue'], 'issue_year': series_info['issue_year'], + 'issueid': series_info['issueid'], 'justthedigits': justthedigits, 'annual_comicid': annual_comicid, 'scangroup': series_info['scangroup']} @@ -1270,11 +1288,12 @@ class FileChecker(object): 'sub': series_info['sub'], 'comiclocation': series_info['comiclocation'], 'series_name': series_info['series_name'], - 'alt_series': series_info['alt_series'], - 'alt_issue': series_info['alt_issue'], + 'alt_series': series_info['alt_series'], + 'alt_issue': series_info['alt_issue'], 'issue_number': series_info['issue_number'], 'series_volume': series_info['series_volume'], 'issue_year': series_info['issue_year'], + 'issueid': series_info['issueid'], 'scangroup': series_info['scangroup']} diff --git a/mylar/webserve.py b/mylar/webserve.py index 0952cf4e..d7026950 100644 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -4545,7 +4545,7 @@ class WebInterface(object): #---- # to be implemented in the future. if mylar.INSTALL_TYPE == 'git': - branch_history, err = mylar.versioncheck.runGit("log --pretty=format:'%h - %cr - %an - %s' -n 5") + branch_history, err = mylar.versioncheck.runGit('log --pretty=format:"%h - %cr - %an - %s" -n 5') #here we pass the branch_history to the pretty_git module to break it down if branch_history: br_hist = self.pretty_git(branch_history) @@ -4649,6 +4649,7 @@ class WebInterface(object): "sab_priority": mylar.CONFIG.SAB_PRIORITY, "sab_directory": mylar.CONFIG.SAB_DIRECTORY, "sab_to_mylar": helpers.checked(mylar.CONFIG.SAB_TO_MYLAR), + "sab_version": mylar.CONFIG.SAB_VERSION, "sab_client_post_processing": helpers.checked(mylar.CONFIG.SAB_CLIENT_POST_PROCESSING), "nzbget_host": mylar.CONFIG.NZBGET_HOST, "nzbget_port": mylar.CONFIG.NZBGET_PORT, @@ -5168,7 +5169,12 @@ class WebInterface(object): else: verify = False + version = 'Unknown' try: + v = requests.get(querysab, params={'mode': 'version'}, verify=verify) + if str(v.status_code) == '200': + logger.fdebug('sabnzbd version: %s' % v.content) + version = v.text r = requests.get(querysab, params=payload, verify=verify) except Exception, e: logger.warn('Error fetching data from %s: %s' % (querysab, e)) @@ -5183,6 +5189,10 @@ class WebInterface(object): verify = False try: + v = requests.get(querysab, params={'mode': 'version'}, verify=verify) + if str(v.status_code) == '200': + logger.fdebug('sabnzbd version: %s' % v.text) + version = v.text r = requests.get(querysab, params=payload, verify=verify) except Exception, e: logger.warn('Error fetching data from %s: %s' % (sabhost, e)) @@ -5191,7 +5201,7 @@ class WebInterface(object): return 'Unable to retrieve data from SABnzbd' - logger.info('status code: ' + str(r.status_code)) + logger.fdebug('status code: ' + str(r.status_code)) if str(r.status_code) != '200': logger.warn('Unable to properly query SABnzbd @' + sabhost + ' [Status Code returned: ' + str(r.status_code) + ']') @@ -5215,7 +5225,9 @@ class WebInterface(object): mylar.CONFIG.SAB_APIKEY = q_apikey logger.info('APIKey provided is the FULL APIKey which is the correct key. You still need to SAVE the config for the changes to be applied.') logger.info('Connection to SABnzbd tested sucessfully') - return "Successfully verified APIkey" + mylar.CONFIG.SAB_VERSION = version + return json.dumps({"status": "Successfully verified APIkey.", "version": str(version)}) + SABtest.exposed = True def NZBGet_test(self, nzbhost=None, nzbport=None, nzbusername=None, nzbpassword=None):