From 96dfe7d765a1f87e7d90523ee4647c1fb73a7d4f Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Thu, 24 Sep 2015 21:21:49 +0300 Subject: [PATCH] Fixed torrent file handling torrents sometimes comes as single file, however, processors (Sickbeard for example) are expecting isolated folder. This patch will make sure that if processed item is not a directory, then it will create a directory (similar to file name) and move the media there. --- TorrentToMedia.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 6fd691c0..8ebdb15b 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -97,7 +97,12 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, if clientAgent != 'manual': core.pause_torrent(clientAgent, inputHash, inputID, inputName) - if uniquePath: + # Incase input is not directory, make sure to create one. + # This way Processing is isolated. + if not os.path.isdir(os.path.join(inputDirectory, inputName)): + basename = os.path.splitext(core.sanitizeName(inputName))[0] + outputDestination = os.path.join(core.OUTPUTDIRECTORY, inputCategory, basename) + elif uniquePath: outputDestination = os.path.normpath( core.os.path.join(core.OUTPUTDIRECTORY, inputCategory, core.sanitizeName(inputName))) else: