diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 70ebd5ba..0f453b39 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -84,6 +84,11 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, except: Torrent_NoLink = 0 + try: + keep_archive = int(section[usercat]["keep_archive"]) + except: + keep_archive = 0 + try: extract = int(section[usercat]['extract']) except: @@ -178,7 +183,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, if extract == 1: logger.debug('Checking for archives to extract in directory: %s' % (outputDestination)) - core.extractFiles(outputDestination) + core.extractFiles(inputDirectory, outputDestination, keep_archive) if not inputCategory in core.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later. core.flatten(outputDestination) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 2fd39584..1885b750 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -51,6 +51,7 @@ web_root = # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 method = renamer delete_failed = 0 wait_for = 2 @@ -80,6 +81,7 @@ delete_failed = 0 # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 process_method = # force processing of already processed content when running a manual scan. force = 0 @@ -112,6 +114,7 @@ delete_failed = 0 # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 extract = 1 nzbExtractionBy = Downloader wait_for = 2 @@ -138,6 +141,7 @@ wait_for = 2 # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 @@ -162,6 +166,7 @@ ssl=0 # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 @@ -187,6 +192,7 @@ web_root = # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 @@ -341,6 +347,7 @@ #Enable/Disable this subsection category enabled = 0 Torrent_NoLink = 0 + keep_archive = 1 extract = 1 #Enable if you are sending commands to a remote server for this category remote_path = 0 diff --git a/core/nzbToMediaUtil.py b/core/nzbToMediaUtil.py index 27af0019..39f7c788 100644 --- a/core/nzbToMediaUtil.py +++ b/core/nzbToMediaUtil.py @@ -993,7 +993,7 @@ def find_imdbid(dirName, inputName): logger.warning('Unable to find a imdbID for %s' % (inputName)) return imdbid -def extractFiles(src, dst=None): +def extractFiles(src, dst=None, keep_archive = None): extracted_folder = [] extracted_archive = [] @@ -1018,8 +1018,8 @@ def extractFiles(src, dst=None): fullFileName = os.path.basename(inputFile) archiveName = os.path.splitext(fullFileName)[0] archiveName = re.sub(r"part[0-9]+", "", archiveName) - if not archiveName in extracted_archive: - continue # don't remove if we haven't extracted this archive. + if not archiveName in extracted_archive or keep_archive == True: + continue # don't remove if we haven't extracted this archive, or if we want to preserve them. logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder)) try: if not os.access(inputFile, os.W_OK):