mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
Flatten after extract. Extract SubDirs and multi archives. Typo.
This commit is contained in:
parent
663cd22934
commit
863fd3ef5c
2 changed files with 19 additions and 18 deletions
|
@ -159,15 +159,15 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
except:
|
except:
|
||||||
logger.error("Failed to link: %s to %s" % (inputFile, targetFile))
|
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)
|
inputName, outputDestination = convert_to_ascii(inputName, outputDestination)
|
||||||
|
|
||||||
if extract == 1:
|
if extract == 1:
|
||||||
logger.debug('Checking for archives to extract in directory: %s' % (outputDestination))
|
logger.debug('Checking for archives to extract in directory: %s' % (outputDestination))
|
||||||
nzbtomedia.extractFiles(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:
|
# Now check if video files exist in destination:
|
||||||
if sectionName in ["SickBeard", "NzbDrone", "CouchPotato"]:
|
if sectionName in ["SickBeard", "NzbDrone", "CouchPotato"]:
|
||||||
numVideos = len(
|
numVideos = len(
|
||||||
|
|
|
@ -630,7 +630,7 @@ def create_torrent_class(clientAgent):
|
||||||
|
|
||||||
|
|
||||||
def pause_torrent(clientAgent, inputHash, inputID, inputName):
|
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 != "":
|
if clientAgent == 'utorrent' and nzbtomedia.TORRENT_CLASS != "":
|
||||||
nzbtomedia.TORRENT_CLASS.stop(inputHash)
|
nzbtomedia.TORRENT_CLASS.stop(inputHash)
|
||||||
|
@ -836,26 +836,27 @@ def find_imdbid(dirName, inputName):
|
||||||
|
|
||||||
def extractFiles(src, dst=None):
|
def extractFiles(src, dst=None):
|
||||||
extracted_folder = []
|
extracted_folder = []
|
||||||
|
extracted_archive = []
|
||||||
|
|
||||||
for inputFile in listMediaFiles(src, media=False, audio=False, meta=False, archives=True):
|
for inputFile in listMediaFiles(src, media=False, audio=False, meta=False, archives=True):
|
||||||
dirPath = os.path.dirname(inputFile)
|
dirPath = os.path.dirname(inputFile)
|
||||||
fullFileName = os.path.basename(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:
|
if dirPath in extracted_folder and archiveName in extracted_archive:
|
||||||
break
|
continue # no need to extract this, but keep going to look for other archives and sub directories.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if extractor.extract(inputFile, dirPath or dst):
|
if extractor.extract(inputFile, dirPath or dst):
|
||||||
extracted_folder.append(dirPath or dst)
|
extracted_folder.append(dirPath or dst)
|
||||||
|
extracted_archive.append(archiveName)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error("Extraction failed for: %s" % (fullFileName))
|
logger.error("Extraction failed for: %s" % (fullFileName))
|
||||||
|
|
||||||
if extracted_folder:
|
|
||||||
for folder in extracted_folder:
|
for folder in extracted_folder:
|
||||||
for inputFile in listMediaFiles(folder):
|
for inputFile in listMediaFiles(folder, media=False, audio=False, meta=False, archives=True):
|
||||||
fullFileName = os.path.basename(inputFile)
|
fullFileName = os.path.basename(inputFile)
|
||||||
|
|
||||||
if is_archive_file(inputFile):
|
|
||||||
logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder))
|
logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder))
|
||||||
try:
|
try:
|
||||||
os.remove(inputFile)
|
os.remove(inputFile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue