diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 4b4906e1..4b1ebfec 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -159,15 +159,15 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, except: logger.error("Failed to link: %s to %s" % (inputFile, targetFile)) - if not inputCategory in nzbtomedia.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later. - nzbtomedia.flatten(outputDestination) - inputName, outputDestination = convert_to_ascii(inputName, outputDestination) if extract == 1: logger.debug('Checking for archives to extract in directory: %s' % (outputDestination)) nzbtomedia.extractFiles(outputDestination) + if not inputCategory in nzbtomedia.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later. + nzbtomedia.flatten(outputDestination) + # Now check if video files exist in destination: if sectionName in ["SickBeard", "NzbDrone", "CouchPotato"]: numVideos = len( diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index 5b4e04ce..945e7975 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -630,7 +630,7 @@ def create_torrent_class(clientAgent): def pause_torrent(clientAgent, inputHash, inputID, inputName): - logger.debug("Stoping torrent %s in %s while processing" % (inputName, clientAgent)) + logger.debug("Stopping torrent %s in %s while processing" % (inputName, clientAgent)) if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "": nzbtomedia.TORRENT_CLASS.stop(inputHash) @@ -836,32 +836,33 @@ def find_imdbid(dirName, inputName): def extractFiles(src, dst=None): extracted_folder = [] + extracted_archive = [] for inputFile in listMediaFiles(src, media=False, audio=False, meta=False, archives=True): dirPath = os.path.dirname(inputFile) fullFileName = os.path.basename(inputFile) + archiveName = os.path.splitext(fullFileName)[0] + archiveName = re.sub(r"part[0-9]+", "", archiveName) - if dirPath in extracted_folder: - break + if dirPath in extracted_folder and archiveName in extracted_archive: + continue # no need to extract this, but keep going to look for other archives and sub directories. try: if extractor.extract(inputFile, dirPath or dst): extracted_folder.append(dirPath or dst) + extracted_archive.append(archiveName) except Exception, e: logger.error("Extraction failed for: %s" % (fullFileName)) - if extracted_folder: - for folder in extracted_folder: - for inputFile in listMediaFiles(folder): - fullFileName = os.path.basename(inputFile) - - if is_archive_file(inputFile): - logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder)) - try: - os.remove(inputFile) - time.sleep(1) - except: - logger.debug("Unable to remove file %s" % (inputFile)) + for folder in extracted_folder: + for inputFile in listMediaFiles(folder, media=False, audio=False, meta=False, archives=True): + fullFileName = os.path.basename(inputFile) + logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder)) + try: + os.remove(inputFile) + time.sleep(1) + except: + logger.debug("Unable to remove file %s" % (inputFile)) def import_subs(filename): if not nzbtomedia.GETSUBS: