From 5bf465b88379623e7fedcb3f532ce7822ff20904 Mon Sep 17 00:00:00 2001 From: Noam Date: Fri, 4 Mar 2016 15:29:52 +0200 Subject: [PATCH] Go Back to Previous Folder Name - Go back to previous folder name method --- headphones/deluge.py | 5 +++-- headphones/searcher.py | 19 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/headphones/deluge.py b/headphones/deluge.py index 1acdd851..e07cc7c1 100644 --- a/headphones/deluge.py +++ b/headphones/deluge.py @@ -58,7 +58,8 @@ def _scrubber(text): # URL parameter values text = re.sub('=[0-9a-zA-Z]*', '=REMOVED', text) # Local host with port - text = re.sub('\:\/\/.*\:', '://REMOVED:', text) + # text = re.sub('\:\/\/.*\:', '://REMOVED:', text) # just host + text = re.sub('\:\/\/.*\:[0-9]*', '://REMOVED:', text) # Session cookie text = re.sub("_session_id'\: '.*'", "_session_id': 'REMOVED'", text) # Local Windows user path @@ -197,7 +198,7 @@ def getTorrentFolder(result): result['hash'], ["total_done"] ], - "id": 22}) + "id": 21}) response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth, verify=deluge_verify_cert) result['total_done'] = json.loads(response.text)['result']['total_done'] diff --git a/headphones/searcher.py b/headphones/searcher.py index d4a2b9c9..ee561823 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -895,9 +895,9 @@ def send_to_downloader(data, bestqual, album): try: # Add torrent if bestqual[3] == 'rutracker.org': - torrentid = deluge.addTorrent('', data, name=folder_name) + torrentid = deluge.addTorrent('', data) else: - torrentid = deluge.addTorrent(bestqual[2], name=folder_name) + torrentid = deluge.addTorrent(bestqual[2]) if not torrentid: logger.error("Error sending torrent to Deluge. Are you sure it's running? Maybe the torrent already exists?") @@ -920,14 +920,13 @@ def send_to_downloader(data, bestqual, album): if headphones.CONFIG.DELUGE_DONE_DIRECTORY: deluge.setTorrentPath({'hash': torrentid}) - # I only just realized this function is useless... - # Hadn't realized folder_name was already being set to Artist - Album - #folder_name = deluge.getTorrentFolder({'hash': torrentid}) - #if folder_name: - # logger.info('Torrent folder name: %s' % folder_name) - #else: - # logger.error('Torrent folder name could not be determined') - # return + # Get folder name from Deluge, it's usually the torrent name + folder_name = deluge.getTorrentFolder({'hash': torrentid}) + if folder_name: + logger.info('Torrent folder name: %s' % folder_name) + else: + logger.error('Torrent folder name could not be determined') + return except Exception as e: logger.error('Error sending torrent to Deluge: %s' % str(e))