IMP: Change qBittorrent start-on-load from two-way force/pause start, to a three-way force/pause/default start. IMP: Add variable to distinguish between old and new WebAPI in qBittorrent

This commit is contained in:
Arathen 2019-02-05 18:32:08 +11:00 committed by evilhero
parent d4e930d4a6
commit 954369f7b0
4 changed files with 32 additions and 11 deletions

View File

@ -703,9 +703,21 @@
<input type="text" name="qbittorrent_folder" value="${config['qbittorrent_folder']}" size="30"><br/>
<small>Folder path where torrents will be assigned to</small>
</div>
<div class="row left">
<input type="radio" name="qbittorrent_loadaction" id="qbittorrent_clientdefault" value="0" ${config['qbittorrent_clientdefault']}>Add torrent using client default action
</div>
<div class="row left">
<input type="radio" name="qbittorrent_loadaction" id="qbittorrent_forcestart" value="1" ${config['qbittorrent_forcestart']}>Add torrent and force start
</div>
<div class="row left">
<input type="radio" name="qbittorrent_loadaction" id="qbittorrent_addpaused" value="2" ${config['qbittorrent_addpaused']}>Add torrent paused
</div>
<div class="row checkbox left clearfix">
<input id="qbittorrent_startonload" type="checkbox" name="qbittorrent_startonload" value="1" ${config['qbittorrent_startonload']} /><label>Start Torrent on Successful Load</label>
<small>Automatically start torrent on successful loading within qBittorrent client</small>
<small>qBittorrent "Add torrent" options</small>
</div>
<div class="row checkbox left clearfix">
<input id="qbittorrent_newapi" type="checkbox" name="qbittorrent_newapi" value="1" ${config['qbittorrent_newapi']} /><label>qBittorrent version >4.1.0? (Use new WebAPI)</label>
<small>Use the new qBittorrent client WebAPI available since v4.1.0</small>
</div>
</fieldset>
</div>

View File

@ -348,7 +348,8 @@ _CONFIG_DEFINITIONS = OrderedDict({
'QBITTORRENT_PASSWORD': (str, 'qBittorrent', None),
'QBITTORRENT_LABEL': (str, 'qBittorrent', None),
'QBITTORRENT_FOLDER': (str, 'qBittorrent', None),
'QBITTORRENT_STARTONLOAD': (bool, 'qBittorrent', False),
'QBITTORRENT_LOADACTION': (int, 'qBittorrent', 0), #0': client default, #1': force start, #2': add paused
'QBITTORRENT_NEWAPI': (bool, 'qBittorrent', True),
'OPDS_ENABLE': (bool, 'OPDS', False),
'OPDS_AUTHENTICATION': (bool, 'OPDS', False),

View File

@ -111,17 +111,22 @@ class TorrentClient(object):
else:
logger.debug('Successfully submitted for add via file. Verifying item is now on client.')
if mylar.CONFIG.QBITTORRENT_STARTONLOAD:
logger.info('attempting to start')
startit = self.client.force_start(hash)
logger.info('startit returned:' + str(startit))
else:
logger.info('attempting to pause torrent incase it starts')
if mylar.CONFIG.QBITTORRENT_LOADACTION == 1:
logger.info('Attempting to force start torrent')
try:
startit = self.client.force_start(hash)
logger.info('startit returned:' + str(startit))
except:
logger.warn('Unable to force start torrent - please check your client.')
elif mylar.CONFIG.QBITTORRENT_LOADACTION == 2:
logger.info('Attempting to pause torrent after loading')
try:
startit = self.client.pause(hash)
logger.info('startit paused:' + str(startit))
except:
logger.warn('Unable to pause torrent - possibly already paused?')
else:
logger.info('Client default add action selected. Doing nothing.')
try:
time.sleep(5) # wait 5 in case it's not populated yet.

View File

@ -4739,7 +4739,10 @@ class WebInterface(object):
"qbittorrent_password": mylar.CONFIG.QBITTORRENT_PASSWORD,
"qbittorrent_label": mylar.CONFIG.QBITTORRENT_LABEL,
"qbittorrent_folder": mylar.CONFIG.QBITTORRENT_FOLDER,
"qbittorrent_startonload": helpers.checked(mylar.CONFIG.QBITTORRENT_STARTONLOAD),
"qbittorrent_clientdefault": helpers.radio(mylar.CONFIG.QBITTORRENT_LOADACTION, 0),
"qbittorrent_forcestart": helpers.radio(mylar.CONFIG.QBITTORRENT_LOADACTION, 1),
"qbittorrent_addpaused": helpers.radio(mylar.CONFIG.QBITTORRENT_LOADACTION, 2),
"qbittorrent_newapi": helpers.checked(mylar.CONFIG.QBITTORRENT_NEWAPI),
"blackhole_dir": mylar.CONFIG.BLACKHOLE_DIR,
"usenet_retention": mylar.CONFIG.USENET_RETENTION,
"nzbsu": helpers.checked(mylar.CONFIG.NZBSU),
@ -5104,7 +5107,7 @@ class WebInterface(object):
def configUpdate(self, **kwargs):
checked_configs = ['enable_https', 'launch_browser', 'syno_fix', 'auto_update', 'annuals_on', 'api_enabled', 'nzb_startup_search',
'enforce_perms', 'sab_to_mylar', 'torrent_local', 'torrent_seedbox', 'rtorrent_ssl', 'rtorrent_verify', 'rtorrent_startonload',
'enable_torrents', 'qbittorrent_startonload', 'enable_rss', 'nzbsu', 'nzbsu_verify',
'enable_torrents', 'qbittorrent_newapi', 'enable_rss', 'nzbsu', 'nzbsu_verify',
'dognzb', 'dognzb_verify', 'experimental', 'enable_torrent_search', 'enable_public', 'enable_32p', 'enable_torznab',
'newznab', 'use_minsize', 'use_maxsize', 'ddump', 'failed_download_handling', 'sab_client_post_processing', 'nzbget_client_post_processing',
'failed_auto', 'post_processing', 'enable_check_folder', 'enable_pre_scripts', 'enable_snatch_script', 'enable_extra_scripts',