From fee3ec2897fdbf25aa909405118f2ce9a4e572bc Mon Sep 17 00:00:00 2001 From: Clinton Hall Date: Sun, 24 Mar 2013 18:24:39 -0700 Subject: [PATCH] Only extract part1 of multipart. fixes #100 --- TorrentToMedia.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 2ec695d1..3d626d3a 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -30,6 +30,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash): root = int(0) video = int(0) video2 = int(0) + num_compressed = int(0) extractionSuccess = False Logger.debug("MAIN: Received Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory) @@ -51,7 +52,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash): for file in filenames: filePath = os.path.join(dirpath, file) - fileExtension = os.path.splitext(file)[1] + fileName, fileExtension = os.path.splitext(file) targetDirectory = os.path.join(outputDestination, file) if root == 1: @@ -95,6 +96,13 @@ def main(inputDirectory, inputName, inputCategory, inputHash): Logger.error("MAIN: Failed to link file: %s", file) Logger.debug(e) elif fileExtension in compressedContainer: + if re.search(r'\d+', os.path.splitext(fileName)[1]): # find part numbers in second "extension" from right + part = int(re.search(r'\d+', os.path.splitext(fileName)[1]).group()) + if part == 1: # we only want to extract the primary part. + Logger.info("MAIN: Found primary part of a multi-part archive %s. Extracting", file) + else: + Logger.info("MAIN: Found part %s of a multi-part archive %s. Ignoring", part, file) + continue Logger.info("MAIN: Found compressed archive %s for file %s", fileExtension, filePath) try: extractor.extract(filePath, outputDestination)