diff --git a/deluge/common.py b/deluge/common.py index 0cde41b0b..9208a84b2 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -63,7 +63,6 @@ if not hasattr(json, "dumps"): json.load = load import pkg_resources -import xdg, xdg.BaseDirectory import gettext import locale @@ -150,6 +149,7 @@ def get_default_config_dir(filename=None): else: return os.path.join(os.environ.get("APPDATA"), "deluge") else: + import xdg.BaseDirectory if filename: return os.path.join(xdg.BaseDirectory.save_config_path("deluge"), filename) else: diff --git a/deluge/plugins/autoadd/autoadd/core.py b/deluge/plugins/autoadd/autoadd/core.py index ac7a5492b..a45a90679 100644 --- a/deluge/plugins/autoadd/autoadd/core.py +++ b/deluge/plugins/autoadd/autoadd/core.py @@ -56,6 +56,7 @@ DEFAULT_PREFS = { OPTIONS_AVAILABLE = { #option: builtin "enabled":False, "path":False, + "append_extension":False, "abspath":False, "download_location":True, "max_download_speed":True, @@ -70,7 +71,8 @@ OPTIONS_AVAILABLE = { #option: builtin "move_completed":True, "move_completed_path":True, "label":False, - "add_paused":True + "add_paused":True, + "queue_to_top":False } MAX_NUM_ATTEMPTS = 10 @@ -146,7 +148,7 @@ class Core(CorePluginBase): raise Exception("Path is already being watched.") for key in options.keys(): if not key in OPTIONS_AVAILABLE: - if not key in [key+'_toggle' for key in OPTIONS_AVAILABLE.iterkeys()]: + if not key in [key2+'_toggle' for key2 in OPTIONS_AVAILABLE.iterkeys()]: raise Exception("autoadd: Invalid options key:%s" % key) #disable the watch loop if it was active if watchdir_id in self.update_timers: @@ -231,13 +233,24 @@ class Core(CorePluginBase): # The torrent looks good, so lets add it to the session torrent_id = component.get("TorrentManager").add(filedump=filedump, filename=filename, options=opts) - if ('Label' in component.get("CorePluginManager").get_enabled_plugins()) and torrent_id: - if watchdir.get('label_toggle', True) and watchdir.get('label'): - label = component.get("CorePlugin.Label") - if not watchdir['label'] in label.get_labels(): - label.add(watchdir['label']) - label.set_torrent(torrent_id, watchdir['label']) - os.remove(filepath) + if torrent_id: + if 'Label' in component.get("CorePluginManager").get_enabled_plugins(): + if watchdir.get('label_toggle', True) and watchdir.get('label'): + label = component.get("CorePlugin.Label") + if not watchdir['label'] in label.get_labels(): + label.add(watchdir['label']) + label.set_torrent(torrent_id, watchdir['label']) + if watchdir.get('queue_to_top_toggle'): + if watchdir.get('queue_to_top', True): + component.get("TorrentManager").queue_top(torrent_id) + else: + component.get("TorrentManager").queue_bottom(torrent_id) + if watchdir.get('append_extension_toggle', False): + if not watchdir.get('append_extension'): + watchdir['append_extension'] = ".added" + os.rename(filepath, filepath + watchdir['append_extension']) + else: + os.remove(filepath) @export def enable_watchdir(self, watchdir_id): diff --git a/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade b/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade index bdb569036..74870b235 100644 --- a/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade +++ b/deluge/plugins/autoadd/autoadd/data/autoadd_options.glade @@ -83,9 +83,11 @@ True + vertical True + vertical True @@ -94,6 +96,7 @@ True 6 + vertical True @@ -106,6 +109,7 @@ True + vertical True @@ -170,6 +174,89 @@ 0 + + + True + 0 + none + + + True + 12 + + + True + + + True + vertical + + + Delete .torrent after adding + True + True + False + True + True + + + 0 + + + + + True + + + Append extension after adding: + True + True + False + True + isnt_append_extension + + + + 0 + + + + + True + True + + .added + + + 1 + + + + + 1 + + + + + + + + + + + True + <b>Torrent File Action</b> + True + + + label_item + + + + + 1 + + True @@ -182,6 +269,7 @@ True + vertical Set download location @@ -244,7 +332,7 @@ False - 1 + 2 @@ -259,6 +347,7 @@ True + vertical Set move completed location @@ -336,7 +425,7 @@ False - 2 + 3 @@ -392,7 +481,7 @@ - 3 + 4 @@ -411,6 +500,7 @@ True 6 + vertical @@ -640,14 +730,16 @@ - 2 - 3 + 3 + 4 GTK_FILL True + 0 + 0 12 @@ -661,8 +753,8 @@ - 3 - 4 + 4 + 5 @@ -676,8 +768,8 @@ - 1 - 2 + 2 + 3 GTK_FILL @@ -694,8 +786,8 @@ 2 3 - 3 - 4 + 4 + 5 GTK_FILL @@ -712,8 +804,8 @@ 1 2 - 3 - 4 + 4 + 5 GTK_FILL @@ -730,14 +822,15 @@ 1 2 - 2 - 3 + 3 + 4 True + True Yes @@ -768,8 +861,8 @@ 1 2 - 1 - 2 + 2 + 3 GTK_FILL GTK_FILL @@ -786,8 +879,8 @@ 2 3 - 2 - 3 + 3 + 4 GTK_FILL @@ -805,6 +898,7 @@ True + True Yes @@ -824,7 +918,6 @@ True True False - True True add_paused @@ -863,10 +956,56 @@ - + + Queue to: + True + True + False + True + + + + 1 + 2 + - + + True + True + + + Top + True + True + False + True + True + + + 0 + + + + + Bottom + True + True + False + True + queue_to_top + + + 1 + + + + + 1 + 2 + 1 + 2 + @@ -911,6 +1050,7 @@ True + vertical 1 diff --git a/deluge/plugins/autoadd/autoadd/gtkui.py b/deluge/plugins/autoadd/autoadd/gtkui.py index 4541998f3..2dc770614 100644 --- a/deluge/plugins/autoadd/autoadd/gtkui.py +++ b/deluge/plugins/autoadd/autoadd/gtkui.py @@ -51,7 +51,7 @@ from common import get_resource class OptionsDialog(): spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"] spin_int_ids = ["max_upload_slots", "max_connections"] - chk_ids = ["stop_at_ratio", "remove_at_ratio", "move_completed", "add_paused", "auto_managed"] + chk_ids = ["stop_at_ratio", "remove_at_ratio", "move_completed", "add_paused", "auto_managed", "queue_to_top"] def __init__(self): pass @@ -87,6 +87,8 @@ class OptionsDialog(): def load_options(self, options): self.glade.get_widget('enabled').set_active(options.get('enabled', False)) + self.glade.get_widget('append_extension_toggle').set_active(options.get('append_extension_toggle', False)) + self.glade.get_widget('append_extension').set_text(options.get('append_extension', '.added')) self.glade.get_widget('download_location_toggle').set_active(options.get('download_location_toggle', False)) self.glade.get_widget('label').set_text(options.get('label', '')) self.glade.get_widget('label_toggle').set_active(options.get('label_toggle', False)) @@ -97,7 +99,9 @@ class OptionsDialog(): self.glade.get_widget(id).set_active(bool(options.get(id, True))) self.glade.get_widget(id+'_toggle').set_active(options.get(id+'_toggle', False)) if not options.get('add_paused', True): - self.glade.get_widget('isnt_add_paused').set_active(True) + self.glade.get_widget('isnt_add_paused').set_active(True) + if not options.get('queue_to_top', True): + self.glade.get_widget('isnt_queue_to_top').set_active(True) if not options.get('auto_managed', True): self.glade.get_widget('isnt_auto_managed').set_active(True) for field in ['move_completed_path', 'path', 'download_location']: @@ -121,9 +125,9 @@ class OptionsDialog(): client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins) def set_sensitive(self): - maintoggles = ['download_location', 'move_completed', 'label', \ + maintoggles = ['download_location', 'append_extension', 'move_completed', 'label', \ 'max_download_speed', 'max_upload_speed', 'max_connections', \ - 'max_upload_slots', 'add_paused', 'auto_managed', 'stop_at_ratio'] + 'max_upload_slots', 'add_paused', 'auto_managed', 'stop_at_ratio', 'queue_to_top'] [self.on_toggle_toggled(self.glade.get_widget(x+'_toggle')) for x in maintoggles] def on_toggle_toggled(self, tb): @@ -132,6 +136,8 @@ class OptionsDialog(): if toggle == 'download_location': self.glade.get_widget('download_location_chooser').set_sensitive(isactive) self.glade.get_widget('download_location_entry').set_sensitive(isactive) + elif toggle == 'append_extension': + self.glade.get_widget('append_extension').set_sensitive(isactive) elif toggle == 'move_completed': self.glade.get_widget('move_completed_path_chooser').set_sensitive(isactive) self.glade.get_widget('move_completed_path_entry').set_sensitive(isactive) @@ -149,6 +155,9 @@ class OptionsDialog(): elif toggle == 'add_paused': self.glade.get_widget('add_paused').set_sensitive(isactive) self.glade.get_widget('isnt_add_paused').set_sensitive(isactive) + elif toggle == 'queue_to_top': + self.glade.get_widget('queue_to_top').set_sensitive(isactive) + self.glade.get_widget('isnt_queue_to_top').set_sensitive(isactive) elif toggle == 'auto_managed': self.glade.get_widget('auto_managed').set_sensitive(isactive) self.glade.get_widget('isnt_auto_managed').set_sensitive(isactive) @@ -193,6 +202,8 @@ class OptionsDialog(): options['path'] = self.glade.get_widget('path_entry').get_text() options['download_location'] = self.glade.get_widget('download_location_entry').get_text() options['move_completed_path'] = self.glade.get_widget('move_completed_path_entry').get_text() + options['append_extension_toggle'] = self.glade.get_widget('append_extension_toggle').get_active() + options['append_extension'] = self.glade.get_widget('append_extension').get_text() options['download_location_toggle'] = self.glade.get_widget('download_location_toggle').get_active() options['label'] = self.glade.get_widget('label').get_text().lower() options['label_toggle'] = self.glade.get_widget('label_toggle').get_active() diff --git a/deluge/plugins/autoadd/setup.py b/deluge/plugins/autoadd/setup.py index 6522a92fb..22b250e6c 100644 --- a/deluge/plugins/autoadd/setup.py +++ b/deluge/plugins/autoadd/setup.py @@ -42,7 +42,7 @@ from setuptools import setup __plugin_name__ = "AutoAdd" __author__ = "Chase Sterling" __author_email__ = "chase.sterling@gmail.com" -__version__ = "0.28" +__version__ = "1.01" __url__ = "http://forum.deluge-torrent.org/viewtopic.php?f=9&t=26775" __license__ = "GPLv3" __description__ = "Monitors folders for .torrent files."