From 4008774908e6838aa27ffb2d3cf54d3f730a5bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Tue, 19 Nov 2013 18:51:28 +0100 Subject: [PATCH 1/2] append label unnecessary just set the full path to the dir --- couchpotato/core/downloaders/rtorrent/__init__.py | 8 -------- couchpotato/core/downloaders/rtorrent/main.py | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/couchpotato/core/downloaders/rtorrent/__init__.py b/couchpotato/core/downloaders/rtorrent/__init__.py index 026a56c..684ea45 100755 --- a/couchpotato/core/downloaders/rtorrent/__init__.py +++ b/couchpotato/core/downloaders/rtorrent/__init__.py @@ -59,14 +59,6 @@ config = [{ 'description': 'Also remove the leftover files.', }, { - 'name': 'append_label', - 'label': 'Append Label', - 'default': False, - 'advanced': True, - 'type': 'bool', - 'description': 'Append label to download location. Requires you to set the download location above.', - }, - { 'name': 'paused', 'type': 'bool', 'advanced': True, diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py index d7ae589..8381f0a 100755 --- a/couchpotato/core/downloaders/rtorrent/main.py +++ b/couchpotato/core/downloaders/rtorrent/main.py @@ -125,9 +125,7 @@ class rTorrent(Downloader): if self.conf('label'): torrent.set_custom(1, self.conf('label')) - if self.conf('directory') and self.conf('append_label'): - torrent.set_directory(os.path.join(self.conf('directory'), self.conf('label'))) - elif self.conf('directory'): + if self.conf('directory'): torrent.set_directory(self.conf('directory')) # Set Ratio Group From b7d93b84dd74cdbee01543be17053841de740455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Tue, 19 Nov 2013 18:59:54 +0100 Subject: [PATCH 2/2] option to set download directory in utorrent --- couchpotato/core/downloaders/utorrent/__init__.py | 5 +++++ couchpotato/core/downloaders/utorrent/main.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/couchpotato/core/downloaders/utorrent/__init__.py b/couchpotato/core/downloaders/utorrent/__init__.py index d45e2e6..0c4c323 100644 --- a/couchpotato/core/downloaders/utorrent/__init__.py +++ b/couchpotato/core/downloaders/utorrent/__init__.py @@ -37,6 +37,11 @@ config = [{ 'description': 'Label to add torrent as.', }, { + 'name': 'directory', + 'type': 'directory', + 'description': 'Download to this directory. Keep empty for default uTorrent download directory.', + }, + { 'name': 'remove_complete', 'label': 'Remove torrent', 'default': True, diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py index 1db1b8a..e05d104 100644 --- a/couchpotato/core/downloaders/utorrent/main.py +++ b/couchpotato/core/downloaders/utorrent/main.py @@ -77,6 +77,7 @@ class uTorrent(Downloader): else: info = bdecode(filedata)["info"] torrent_hash = sha1(benc(info)).hexdigest().upper() + torrent_filename = self.createFileName(data, filedata, movie) if data.get('seed_ratio'): @@ -91,11 +92,17 @@ class uTorrent(Downloader): if len(torrent_hash) == 32: torrent_hash = b16encode(b32decode(torrent_hash)) + # Set download directory + if self.conf('directory'): + directory = self.conf('directory') + else: + directory = False + # Send request to uTorrent if data.get('protocol') == 'torrent_magnet': - self.utorrent_api.add_torrent_uri(torrent_filename, data.get('url')) + self.utorrent_api.add_torrent_uri(torrent_filename, data.get('url'), directory) else: - self.utorrent_api.add_torrent_file(torrent_filename, filedata) + self.utorrent_api.add_torrent_file(torrent_filename, filedata, directory) # Change settings of added torrent self.utorrent_api.set_torrent(torrent_hash, torrent_params) @@ -249,13 +256,13 @@ class uTorrentAPI(object): def add_torrent_uri(self, filename, torrent, add_folder = False): action = "action=add-url&s=%s" % urllib.quote(torrent) if add_folder: - action += "&path=%s" % urllib.quote(filename) + action += "&path=%s" % urllib.quote(add_folder) return self._request(action) def add_torrent_file(self, filename, filedata, add_folder = False): action = "action=add-file" if add_folder: - action += "&path=%s" % urllib.quote(filename) + action += "&path=%s" % urllib.quote(add_folder) return self._request(action, {"torrent_file": (ss(filename), filedata)}) def set_torrent(self, hash, params):