From b2ac5bbaf8d8aa5922f79ac75ea8ea40af644e48 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 11 Oct 2015 15:52:43 -0400 Subject: [PATCH] Added option to presrve archive files following extraction. --- TorrentToMedia.py | 7 ++++++- autoProcessMedia.cfg.spec | 7 +++++++ core/nzbToMediaUtil.py | 6 +++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 730ad364..2700aafb 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: @@ -173,7 +178,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 1d493f15..ed84ec1d 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 @@ -110,6 +112,7 @@ delete_failed = 0 # Enable/Disable linking for Torrents Torrent_NoLink = 0 + keep_archive = 1 extract = 1 nzbExtractionBy = Downloader wait_for = 2 @@ -136,6 +139,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 @@ -160,6 +164,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 @@ -185,6 +190,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 @@ -336,6 +342,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 f6491274..29aace05 100644 --- a/core/nzbToMediaUtil.py +++ b/core/nzbToMediaUtil.py @@ -987,7 +987,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 = [] @@ -1012,8 +1012,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):