FIX:(#1633) Various problems related to qBittorrent - labels not being set properly, some qBittorrent settings would not persist across sessions, snatches would cause an error and/or stop the snatch from being sent in some instances (or trigger failed download handling if it was enabled), FIX: Fixed some os.environ problems when using on-snatch scripts combined with one-off downloads

This commit is contained in:
evilhero 2017-05-07 13:44:18 -04:00
parent 3d28371dcb
commit 2bba83a6d3
5 changed files with 36 additions and 25 deletions

View File

@ -896,9 +896,9 @@ def initialize():
QBITTORRENT_HOST = check_setting_str(CFG, 'qBittorrent', 'qbittorrent_host', '')
QBITTORRENT_USERNAME = check_setting_str(CFG, 'qBittorrent', 'qbittorrent_username', '')
QBITTORRENT_PASSWORD = check_setting_str(CFG, 'qBittorrent', 'qbittorrent_password', '')
QBITTORRENT_LABEL = check_setting_str(CFG, 'qBittorrent', 'qbitttorent_label', '')
QBITTORRENT_FOLDER = check_setting_str(CFG, 'qBittorrent', 'qbitttorent_folder', '')
QBITTORRENT_STARTONLOAD = bool(check_setting_int(CFG, 'qBittorrent', 'qbitttorent_startonload', 0))
QBITTORRENT_LABEL = check_setting_str(CFG, 'qBittorrent', 'qbittorrent_label', '')
QBITTORRENT_FOLDER = check_setting_str(CFG, 'qBittorrent', 'qbittorrent_folder', '')
QBITTORRENT_STARTONLOAD = bool(check_setting_int(CFG, 'qBittorrent', 'qbittorrent_startonload', 0))
#add torrents to provider counter.
if ENABLE_TORRENT_SEARCH:

View File

@ -2793,20 +2793,26 @@ def script_env(mode, vars):
os.environ['mylar_release_blackhole'] = vars['nzbinfo']['blackhole']
os.environ['mylar_release_provider'] = vars['provider']
if 'comicinfo' in vars:
os.environ['mylar_comicid'] = vars['comicinfo']['comicid']
os.environ['mylar_issueid'] = vars['comicinfo']['issueid']
try:
os.environ['mylar_comicid'] = vars['comicinfo']['comicid'] #comicid/issueid are unknown for one-offs (should be fixable tho)
except:
pass
try:
os.environ['mylar_issueid'] = vars['comicinfo']['issueid']
except:
pass
os.environ['mylar_comicname'] = vars['comicinfo']['comicname']
os.environ['mylar_issuenumber'] = vars['comicinfo']['issuenumber']
os.environ['mylar_issuenumber'] = str(vars['comicinfo']['issuenumber'])
try:
os.environ['mylar_comicvolume'] = str(vars['comicinfo']['volume'])
except:
pass
try:
os.environ['mylar_seriesyear'] = vars['comicinfo']['seriesyear']
os.environ['mylar_seriesyear'] = str(vars['comicinfo']['seriesyear'])
except:
pass
try:
os.environ['mylar_issuedate'] = vars['comicinfo']['issuedate']
os.environ['mylar_issuedate'] = str(vars['comicinfo']['issuedate'])
except:
pass

View File

@ -1074,7 +1074,7 @@ def torsend2client(seriesname, issue, seriesyear, linkit, site):
logger.info('Connected to qBittorrent! Will try to add torrent now!')
torrent_info = qc.load_torrent(filepath)
if torrent_info:
if torrent_info['status'] is True:
torrent_info['clientmode'] = 'qbittorrent'
torrent_info['link'] = linkit
return torrent_info

View File

@ -15,14 +15,14 @@ class TorrentClient(object):
return self.connect
if not host:
return False
return {'status': False}
try:
logger.info(host)
self.client = client.Client(host)
except Exception as e:
logger.error('Could not create qBittorrent Object' + str(e))
return False
return {'status': False}
else:
try:
self.client.login(username, password)
@ -67,17 +67,17 @@ class TorrentClient(object):
#Check if torrent already added
if self.find_torrent(hash):
logger.info('load_torrent: Torrent already exists!')
return False
return {'status': False}
#should set something here to denote that it's already loaded, and then the failed download checker not run so it doesn't download
#multiple copies of the same issues that's already downloaded
else:
logger.info('Torrent not added yet, trying to add it now!')
try:
torrent_content = open(filepath, 'rb')
tid = self.client.download_from_file(torrent_content, label=mylar.QBITTORRENT_LABEL)
tid = self.client.download_from_file(torrent_content, category=str(mylar.QBITTORRENT_LABEL))
except Exception as e:
logger.debug('Torrent not added')
return False
return {'status': False}
else:
logger.debug('Successfully submitted for add. Verifying item is now on client.')
@ -98,21 +98,26 @@ class TorrentClient(object):
tinfo = self.get_torrent(hash)
except Exception as e:
logger.warn('Torrent was not added! Please check logs')
return False
return {'status': False}
else:
torrent_info = []
logger.info('Torrent successfully added!')
torrent_info['hash'] = hash
filelist = self.client.get_torrent_files(hash)
#logger.info(filelist)
if len(filelist) == 1:
torrent_info['name'] = filelist['name']
to_name = filelist[0]['name']
else:
torrent_info['name'] = tinfo['save_path']
torrent_info['total_filesize'] = tinfo['total_size']
torrent_info['folder'] = tinfo['save_path']
torrent_info['files'] = filelist
torrent_info['time_started'] = tinfo['addition_date']
torrent_info['label'] = mylar.QBITTORRENT_LABEL
to_name = tinfo['save_path']
torrent_info = {'hash': hash,
'files': filelist,
'name': to_name,
'total_filesize': tinfo['total_size'],
'folder': tinfo['save_path'],
'time_started': tinfo['addition_date'],
'label': mylar.QBITTORRENT_LABEL,
'status': True}
#logger.info(torrent_info)
return torrent_info

View File

@ -4156,7 +4156,7 @@ class WebInterface(object):
"qbittorrent_password": mylar.QBITTORRENT_PASSWORD,
"qbittorrent_label": mylar.QBITTORRENT_LABEL,
"qbittorrent_folder": mylar.QBITTORRENT_FOLDER,
"qbittorrent_startonload": mylar.QBITTORRENT_STARTONLOAD,
"qbittorrent_startonload": helpers.checked(mylar.QBITTORRENT_STARTONLOAD),
"blackhole_dir": mylar.BLACKHOLE_DIR,
"usenet_retention": mylar.USENET_RETENTION,
"use_nzbsu": helpers.checked(mylar.NZBSU),