FIX:(#1959) Test connection button will now return proper status response for NZBGet & will also send now when no category is set, FIX: Fix snatch script error when sending from nzbget and using an on snatch script, FIX: When importing files, would not update the status properly to 'Imported' after a successful import and sometimes create an additional empty entry instead

This commit is contained in:
evilhero 2018-05-22 13:01:48 -04:00
parent 4314b8b98c
commit a331449d30
4 changed files with 51 additions and 22 deletions

View File

@ -43,8 +43,9 @@ def movefiles(comicid, comlocation, imported):
logger.info("moving " + srcimp + " ... to " + dstimp)
try:
shutil.move(srcimp, dstimp)
files_moved.append({'srid': imported['srid'],
'filename': impr['comicfilename']})
files_moved.append({'srid': imported['srid'],
'filename': impr['comicfilename'],
'import_id': impr['import_id']})
except (OSError, IOError):
logger.error("Failed to move files - check directories and manually re-run.")

View File

@ -34,8 +34,21 @@ class NZBGet(object):
elif mylar.CONFIG.NZBGET_HOST[:4] == 'http':
protocol = "http"
nzbget_host = mylar.CONFIG.NZBGET_HOST[7:]
self.nzb_url = '%s://%s:%s@%s:%s/xmlrpc' % (protocol, mylar.CONFIG.NZBGET_USERNAME, mylar.CONFIG.NZBGET_PASSWORD, nzbget_host, mylar.CONFIG.NZBGET_PORT)
self.server = xmlrpclib.ServerProxy(self.nzb_url)
url = '%s://'
val = (protocol,)
if mylar.CONFIG.NZBGET_USERNAME is not None:
url = url + '%s:'
val = val + (mylar.CONFIG.NZBGET_USERNAME,)
if mylar.CONFIG.NZBGET_PASSWORD is not None:
url = url + '%s'
val = val + (mylar.CONFIG.NZBGET_PASSWORD,)
if any([mylar.CONFIG.NZBGET_USERNAME, mylar.CONFIG.NZBGET_PASSWORD]):
url = url + '@%s:%s/xmlrpc'
else:
url = url + '%s:%s/xmlrpc'
val = val + (nzbget_host,mylar.CONFIG.NZBGET_PORT,)
self.nzb_url = (url % val)
self.server = xmlrpclib.ServerProxy(self.nzb_url) #,allow_none=True)
def sender(self, filename, test=False):
if mylar.CONFIG.NZBGET_PRIORITY:
@ -59,7 +72,11 @@ class NZBGet(object):
nzbcontent64 = standard_b64encode(nzbcontent)
try:
logger.fdebug('sending now to %s' % self.nzb_url)
sendresponse = self.server.append(filename, nzbcontent64, mylar.CONFIG.NZBGET_CATEGORY, nzbgetpriority, False, False, '', 0, 'SCORE')
if mylar.CONFIG.NZBGET_CATEGORY is None:
nzb_category = ''
else:
nzb_category = mylar.CONFIG.NZBGET_CATEGORY
sendresponse = self.server.append(filename, nzbcontent64, nzb_category, nzbgetpriority, False, False, '', 0, 'SCORE')
except Exception as e:
logger.warn('uh-oh: %s' % e)
return {'status': False}

View File

@ -2809,7 +2809,7 @@ def searcher(nzbprov, nzbname, comicinfo, link, IssueID, ComicID, tmpprov, direc
if mylar.CONFIG.ENABLE_SNATCH_SCRIPT:
if mylar.USE_NZBGET:
clientmode = 'nzbget'
client_id = None
client_id = '%s' % send_to_nzbget['NZBID']
elif mylar.USE_SABNZBD:
clientmode = 'sabnzbd'
client_id = sendtosab['nzo_id']

View File

@ -3085,9 +3085,6 @@ class WebInterface(object):
"IssueDate": AD['Issue_Date'],
"ReleaseDate": AD['Store_Date']}
logger.info('CTRLWRITE TO: ' + str(newCtrl))
logger.info('WRITING: ' + str(newVals))
myDB.upsert("storyarcs", newVals, newCtrl)
@ -3959,11 +3956,21 @@ class WebInterface(object):
'srid': SRID}
self.addbyid(comicinfo['ComicID'], calledby=True, imported=imported, ogcname=comicinfo['ComicName'], nothread=True)
#status update.
ctrlVal = {"ComicID": comicinfo['ComicID']}
newVal = {"Status": 'Imported',
"SRID": SRID}
myDB.upsert("importresults", newVal, ctrlVal)
#if move files wasn't used - we need to update status at this point.
#if mylar.CONFIG.IMP_MOVE is False:
# #status update.
# for f in files:
# ctrlVal = {"ComicID": comicinfo['ComicID'],
# "impID": f['import_id']}
# newVal = {"Status": 'Imported',
# "SRID": SRID,
# "ComicFilename": f['comicfilename'],
# "ComicLocation": f['comiclocation'],
# "Volume": comicinfo['Volume'],
# "IssueNumber": comicinfo['IssueNumber'],
# "ComicName": comicinfo['ComicName'],
# "DynamicName": comicinfo['DynamicName']}
# myDB.upsert("importresults", newVal, ctrlVal)
logger.info('[IMPORT] Successfully verified import sequence data for : ' + comicinfo['ComicName'] + '. Currently adding to your watchlist.')
RemoveIDS.append(comicinfo['ComicID'])
@ -4229,7 +4236,6 @@ class WebInterface(object):
newVal = {"SRID": SRID,
"Status": 'Importing',
"ComicName": ComicName}
myDB.upsert("importresults", newVal, ctrlVal)
if resultset == 0:
@ -5007,10 +5013,6 @@ class WebInterface(object):
logger.fdebug('Now attempting to test NZBGet connection')
if nzbusername is None or nzbpassword is None:
logger.error('No Username / Password provided for NZBGet credentials. Unable to test API key')
return "Invalid Username/Password provided"
logger.info('Now testing connection to NZBGet @ %s:%s' % (nzbhost, nzbport))
if nzbhost[:5] == 'https':
protocol = 'https'
@ -5019,8 +5021,18 @@ class WebInterface(object):
protocol = 'http'
nzbgethost = nzbhost[7:]
nzb_url = '%s://%s:%s@%s:%s/xmlrpc' % (protocol, nzbusername, nzbpassword, nzbgethost, nzbport)
logger.info('nzb_url: %s' % nzb_url)
url = '%s://'
nzbparams = protocol,
if all([nzbusername is not None, nzbpassword is not None]):
url = url + '%s:%s@'
nzbparams = nzbparams + (nzbusername, nzbpassword)
elif nzbusername is not None:
url = url + '%s@'
nzbparams = nzbparams + (nzbusername,)
url = url + '%s:%s/xmlrpc'
nzbparams = nzbparams + (nzbgethost, nzbport,)
nzb_url = (url % nzbparams)
import xmlrpclib
nzbserver = xmlrpclib.ServerProxy(nzb_url)
@ -5029,7 +5041,6 @@ class WebInterface(object):
except Exception as e:
logger.warn('Error fetching data: %s' % e)
return 'Unable to retrieve data from NZBGet'
logger.info('Successfully verified connection to NZBGet at %s:%s' % (nzbgethost, nzbport))
return "Successfully verified connection to NZBGet"
NZBGet_test.exposed = True