From 954369f7b03520f144bd0c68ececfd49e750d288 Mon Sep 17 00:00:00 2001 From: Arathen Date: Tue, 5 Feb 2019 18:32:08 +1100 Subject: [PATCH] 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 --- data/interfaces/default/config.html | 16 ++++++++++++++-- mylar/config.py | 3 ++- mylar/torrent/clients/qbittorrent.py | 17 +++++++++++------ mylar/webserve.py | 7 +++++-- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 44d2eae5..0d301f41 100755 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -703,9 +703,21 @@
Folder path where torrents will be assigned to +
+ Add torrent using client default action +
+
+ Add torrent and force start +
+
+ Add torrent paused +
- - Automatically start torrent on successful loading within qBittorrent client + qBittorrent "Add torrent" options +
+
+ + Use the new qBittorrent client WebAPI available since v4.1.0
diff --git a/mylar/config.py b/mylar/config.py index 233205f2..1e73ec27 100644 --- a/mylar/config.py +++ b/mylar/config.py @@ -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), diff --git a/mylar/torrent/clients/qbittorrent.py b/mylar/torrent/clients/qbittorrent.py index 6643e023..e1fd4571 100644 --- a/mylar/torrent/clients/qbittorrent.py +++ b/mylar/torrent/clients/qbittorrent.py @@ -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. diff --git a/mylar/webserve.py b/mylar/webserve.py index 5a16da32..d3f36fbc 100644 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -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',