diff --git a/couchpotato/core/downloaders/deluge.py b/couchpotato/core/downloaders/deluge.py index 2a386ad..26592ca 100644 --- a/couchpotato/core/downloaders/deluge.py +++ b/couchpotato/core/downloaders/deluge.py @@ -147,7 +147,7 @@ class Deluge(Downloader): 'seed_ratio': torrent['ratio'], 'timeleft': str(timedelta(seconds = torrent['eta'])), 'folder': sp(download_dir if len(torrent_files) == 1 else os.path.join(download_dir, torrent['name'])), - 'files': '|'.join(torrent_files), + 'files': torrent_files, }) return release_downloads diff --git a/couchpotato/core/downloaders/qbittorrent_.py b/couchpotato/core/downloaders/qbittorrent_.py index 349af17..558222d 100644 --- a/couchpotato/core/downloaders/qbittorrent_.py +++ b/couchpotato/core/downloaders/qbittorrent_.py @@ -135,7 +135,7 @@ class qBittorrent(Downloader): 'original_status': torrent.state, 'timeleft': torrent.progress * 100 if torrent.progress else -1, # percentage 'folder': sp(torrent.save_path), - 'files': '|'.join(torrent_files) + 'files': torrent_files }) return release_downloads diff --git a/couchpotato/core/downloaders/rtorrent_.py b/couchpotato/core/downloaders/rtorrent_.py index 6e5c4b6..98946b2 100644 --- a/couchpotato/core/downloaders/rtorrent_.py +++ b/couchpotato/core/downloaders/rtorrent_.py @@ -245,7 +245,7 @@ class rTorrent(Downloader): 'original_status': torrent.state, 'timeleft': str(timedelta(seconds = float(torrent.left_bytes) / torrent.down_rate)) if torrent.down_rate > 0 else -1, 'folder': sp(torrent.directory), - 'files': '|'.join(torrent_files) + 'files': torrent_files }) return release_downloads diff --git a/couchpotato/core/downloaders/transmission.py b/couchpotato/core/downloaders/transmission.py index f49cb9d..dd11166 100644 --- a/couchpotato/core/downloaders/transmission.py +++ b/couchpotato/core/downloaders/transmission.py @@ -141,7 +141,7 @@ class Transmission(Downloader): 'seed_ratio': torrent['uploadRatio'], 'timeleft': str(timedelta(seconds = torrent['eta'])), 'folder': sp(torrent_folder if len(torrent_files) == 1 else os.path.join(torrent_folder, torrent['name'])), - 'files': '|'.join(torrent_files) + 'files': torrent_files }) return release_downloads diff --git a/couchpotato/core/downloaders/utorrent.py b/couchpotato/core/downloaders/utorrent.py index dae8950..671dd9e 100644 --- a/couchpotato/core/downloaders/utorrent.py +++ b/couchpotato/core/downloaders/utorrent.py @@ -184,7 +184,7 @@ class uTorrent(Downloader): 'original_status': torrent[1], 'timeleft': str(timedelta(seconds = torrent[10])), 'folder': sp(torrent[26]), - 'files': '|'.join(torrent_files) + 'files': torrent_files }) return release_downloads diff --git a/couchpotato/core/plugins/renamer.py b/couchpotato/core/plugins/renamer.py index a259802..4726734 100644 --- a/couchpotato/core/plugins/renamer.py +++ b/couchpotato/core/plugins/renamer.py @@ -79,16 +79,22 @@ class Renamer(Plugin): downloader = kwargs.get('downloader') download_id = kwargs.get('download_id') - files = '|'.join([sp(filename) for filename in splitString(kwargs.get('files'), '|')]) + files = [sp(filename) for filename in splitString(kwargs.get('files'), '|')] status = kwargs.get('status', 'completed') release_download = None if not base_folder and media_folder: release_download = {'folder': media_folder} - release_download.update({'id': download_id, 'downloader': downloader, 'status': status, 'files': files} if download_id else {}) - fire_handle = fireEvent if not async else fireEventAsync + if download_id: + release_download.update({ + 'id': download_id, + 'downloader': downloader, + 'status': status, + 'files': files + }) + fire_handle = fireEvent if not async else fireEventAsync fire_handle('renamer.scan', base_folder = base_folder, release_download = release_download) return { @@ -142,7 +148,7 @@ class Renamer(Plugin): log.debug('The provided media folder %s does not exist. Trying to find it in the \'from\' folder.', media_folder) # Update to the from folder - if len(splitString(release_download.get('files'), '|')) == 1: + if len(release_download.get('files'), []) == 1: new_media_folder = from_folder else: new_media_folder = os.path.join(from_folder, os.path.basename(media_folder)) @@ -152,7 +158,7 @@ class Renamer(Plugin): return # Update the files - new_files = [os.path.join(new_media_folder, os.path.relpath(filename, media_folder)) for filename in splitString(release_download.get('files'), '|')] + new_files = [os.path.join(new_media_folder, os.path.relpath(filename, media_folder)) for filename in release_download.get('files', [])] if new_files and not os.path.isfile(new_files[0]): log.error('The provided media folder %s does not exist and its files could also not be found in the \'from\' folder.', media_folder) return @@ -160,7 +166,7 @@ class Renamer(Plugin): # Update release_download info to the from folder log.debug('Release %s found in the \'from\' folder.', media_folder) release_download['folder'] = new_media_folder - release_download['files'] = '|'.join(new_files) + release_download['files'] = new_files media_folder = new_media_folder if media_folder: @@ -182,11 +188,10 @@ class Renamer(Plugin): log.info('Scanning media folder %s...', media_folder) folder = os.path.dirname(media_folder) - if release_download.get('files', ''): - files = splitString(release_download['files'], '|') - + release_files = release_download.get('files', []) + if release_files: # If there is only one file in the torrent, the downloader did not create a subfolder - if len(files) == 1: + if len(release_files) == 1: folder = media_folder else: # Get all files from the specified folder @@ -643,8 +648,8 @@ Remove it if you want it to be renamed (again, or at least let it try again) elif isinstance(release_download, dict): # Tag download_files if they are known - if release_download['files']: - tag_files = splitString(release_download['files'], '|') + if release_download.get('files', []): + tag_files = release_download.get('files', []) # Tag all files in release folder else: @@ -678,8 +683,8 @@ Remove it if you want it to be renamed (again, or at least let it try again) elif isinstance(release_download, dict): # Untag download_files if they are known - if release_download['files']: - tag_files = splitString(release_download['files'], '|') + if release_download.get('files'): + tag_files = release_download.get('files', []) # Untag all files in release folder else: @@ -719,8 +724,8 @@ Remove it if you want it to be renamed (again, or at least let it try again) ignore_files = [] # Find tag on download_files if they are known - if release_download['files']: - tag_files = splitString(release_download['files'], '|') + if release_download.get('files'): + tag_files = release_download.get('files', []) # Find tag on all files in release folder else: @@ -1040,6 +1045,8 @@ Remove it if you want it to be renamed (again, or at least let it try again) except: log.error('Download ID %s from downloader %s not found in releases', (release_download.get('id'), release_download.get('downloader'))) + print rls + if rls: media = db.get('id', rls['media_id']) release_download.update({