From 81efd4bce782fbe39ef7e2899c70464622c6ffab Mon Sep 17 00:00:00 2001 From: jkaberg Date: Sat, 22 Mar 2014 18:35:11 +0100 Subject: [PATCH] [qbittorrent] minor cleanup --- couchpotato/core/downloaders/qbittorrent_.py | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/couchpotato/core/downloaders/qbittorrent_.py b/couchpotato/core/downloaders/qbittorrent_.py index 558222d3..ac48d327 100644 --- a/couchpotato/core/downloaders/qbittorrent_.py +++ b/couchpotato/core/downloaders/qbittorrent_.py @@ -107,25 +107,24 @@ class qBittorrent(Downloader): for torrent in torrents: if torrent.hash in ids: torrent.update_general() # get extra info + torrent_filelist = torrent.get_files() + torrent_files = [] - t_files = torrent.get_files() + torrent_dir = os.path.join(torrent.save_path, torrent.name) - check_dir = os.path.join(torrent.save_path, torrent.name) - if os.path.isdir(check_dir): - torrent.save_path = check_dir + if os.path.isdir(torrent_dir): + torrent.save_path = torrent_dir - if len(t_files) > 1 and os.path.isdir(torrent.save_path): # multi file torrent + if len(torrent_filelist) > 1 and os.path.isdir(torrent_dir): # multi file torrent, path.isdir check makes sure we're not in the root download folder for root, _, files in os.walk(torrent.save_path): for f in files: - p = os.path.join(root, f) - if os.path.isfile(p): - torrent_files.append(sp(p)) + torrent_files.append(sp(os.path.join(root, f))) else: # multi or single file placed directly in torrent.save_path - for f in t_files: - p = os.path.join(torrent.save_path, f.name) - if os.path.isfile(p): - torrent_files.append(sp(p)) + for f in torrent_filelist: + file_path = os.path.join(torrent.save_path, f.name) + if os.path.isfile(file_path): + torrent_files.append(sp(file_path)) release_downloads.append({ 'id': torrent.hash,