From 6550611e020af63a67878d538676378b1398a6bb Mon Sep 17 00:00:00 2001 From: doucheymcdoucherson Date: Sun, 16 Jun 2019 02:00:09 -0700 Subject: [PATCH] deluge options update --- data/interfaces/default/config.html | 16 ++++++++++++++++ mylar/config.py | 3 +++ mylar/torrent/clients/deluge.py | 18 ++++++++++++++++-- mylar/webserve.py | 5 ++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 0722a42e..3c98d5c3 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -673,6 +673,22 @@
Label to be used on the torrents +
+ +
+ Where the torrent will be downloaded to +
+
+ +
+ Path that files will be moved to after download is complete +
+
+
+ + Add the torrent in a paused state +
+

diff --git a/mylar/config.py b/mylar/config.py index dd8c8f7f..63e45bb7 100644 --- a/mylar/config.py +++ b/mylar/config.py @@ -352,6 +352,9 @@ _CONFIG_DEFINITIONS = OrderedDict({ 'DELUGE_USERNAME': (str, 'Deluge', None), 'DELUGE_PASSWORD': (str, 'Deluge', None), 'DELUGE_LABEL': (str, 'Deluge', None), + 'DELUGE_PAUSE': (bool, 'Deluge', False), + 'DELUGE_DOWNLOAD_DIRECTORY': (str, 'Deluge', ""), + 'DELUGE_DONE_DIRECTORY': (str, 'Deluge', ""), 'QBITTORRENT_HOST': (str, 'qBittorrent', None), 'QBITTORRENT_USERNAME': (str, 'qBittorrent', None), diff --git a/mylar/torrent/clients/deluge.py b/mylar/torrent/clients/deluge.py index 15451b85..2f98b726 100644 --- a/mylar/torrent/clients/deluge.py +++ b/mylar/torrent/clients/deluge.py @@ -99,6 +99,18 @@ class TorrentClient(object): def load_torrent(self, filepath): + options = {} + + if mylar.CONFIG.DELUGE_DOWNLOAD_DIRECTORY: + options['download_location'] = mylar.CONFIG.DELUGE_DOWNLOAD_DIRECTORY + + if mylar.CONFIG.DELUGE_DONE_DIRECTORY: + options['move_completed'] = 1 + options['move_completed_path'] = mylar.CONFIG.DELUGE_DONE_DIRECTORY + + if mylar.CONFIG.DELUGE_PAUSE: + options['add_paused'] = int(mylar.CONFIG.DELUGE_PAUSE) + logger.info('filepath to torrent file set to : ' + filepath) torrent_id = False @@ -121,13 +133,13 @@ class TorrentClient(object): else: logger.info('Torrent not added yet, trying to add it now!') try: - torrent_id = self.client.call('core.add_torrent_file', str(os.path.basename(filepath)), base64.encodestring(torrentcontent), '') + torrent_id = self.client.call('core.add_torrent_file', str(os.path.basename(filepath)), base64.encodestring(torrentcontent), options) except Exception as e: logger.debug('Torrent not added') return False else: try: - torrent_id = self.client.call('core.add_torrent_magnet', str(filepath), {}) + torrent_id = self.client.call('core.add_torrent_magnet', str(filepath), options) except Exception as e: logger.debug('Torrent not added') return False @@ -158,10 +170,12 @@ class TorrentClient(object): return {'hash': torrent_info['hash'], 'label': mylar.CONFIG.DELUGE_LABEL, 'folder': torrent_info['save_path'], + 'move path': torrent_info['move_completed_path'], 'total_filesize': torrent_info['total_size'], 'name': torrent_info['name'], 'files': torrent_info['files'], 'time_started': torrent_info['active_time'], + 'pause': torrent_info['paused'], 'completed': torrent_info['is_finished']} diff --git a/mylar/webserve.py b/mylar/webserve.py index 5ee44406..ac9a0ec5 100644 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -4986,6 +4986,9 @@ class WebInterface(object): "deluge_username": mylar.CONFIG.DELUGE_USERNAME, "deluge_password": mylar.CONFIG.DELUGE_PASSWORD, "deluge_label": mylar.CONFIG.DELUGE_LABEL, + "deluge_pause": helpers.checked(mylar.CONFIG.DELUGE_PAUSE), + "deluge_download_directory": mylar.CONFIG.DELUGE_DOWNLOAD_DIRECTORY, + "deluge_done_directory": mylar.CONFIG.DELUGE_DONE_DIRECTORY, "qbittorrent_host": mylar.CONFIG.QBITTORRENT_HOST, "qbittorrent_username": mylar.CONFIG.QBITTORRENT_USERNAME, "qbittorrent_password": mylar.CONFIG.QBITTORRENT_PASSWORD, @@ -5372,7 +5375,7 @@ class WebInterface(object): 'lowercase_filenames', 'autowant_upcoming', 'autowant_all', 'comic_cover_local', 'alternate_latest_series_covers', 'cvinfo', 'snatchedtorrent_notify', 'prowl_enabled', 'prowl_onsnatch', 'pushover_enabled', 'pushover_onsnatch', 'boxcar_enabled', 'boxcar_onsnatch', 'pushbullet_enabled', 'pushbullet_onsnatch', 'telegram_enabled', 'telegram_onsnatch', 'slack_enabled', 'slack_onsnatch', - 'email_enabled', 'email_enc', 'email_ongrab', 'email_onpost', 'opds_enable', 'opds_authentication', 'opds_metainfo', 'enable_ddl'] + 'email_enabled', 'email_enc', 'email_ongrab', 'email_onpost', 'opds_enable', 'opds_authentication', 'opds_metainfo', 'enable_ddl', 'deluge_pause'] for checked_config in checked_configs: if checked_config not in kwargs: