mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
fix single file downloads. fix #314
This commit is contained in:
parent
c54f06f3a5
commit
ce47c5d509
2 changed files with 34 additions and 12 deletions
|
@ -31,7 +31,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
|
|
||||||
logger.debug("Received Directory: %s | Name: %s | Category: %s" % (inputDirectory, inputName, inputCategory))
|
logger.debug("Received Directory: %s | Name: %s | Category: %s" % (inputDirectory, inputName, inputCategory))
|
||||||
|
|
||||||
inputDirectory, inputName, inputCategory, root, single = nzbtomedia.category_search(inputDirectory, inputName,
|
inputDirectory, inputName, inputCategory, root = nzbtomedia.category_search(inputDirectory, inputName,
|
||||||
inputCategory, root,
|
inputCategory, root,
|
||||||
nzbtomedia.CATEGORIES) # Confirm the category by parsing directory structure
|
nzbtomedia.CATEGORIES) # Confirm the category by parsing directory structure
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
|
|
||||||
if root == 1:
|
if root == 1:
|
||||||
if not foundFile:
|
if not foundFile:
|
||||||
logger.debug("Looking for %s in: %s" % (inputName, fullFileName))
|
logger.debug("Looking for %s in: %s" % (inputName, inputFile))
|
||||||
if (nzbtomedia.sanitizeName(inputName) in nzbtomedia.sanitizeName(fullFileName)) or (
|
if (nzbtomedia.sanitizeName(inputName) in nzbtomedia.sanitizeName(inputFile)) or (
|
||||||
nzbtomedia.sanitizeName(fileName) in nzbtomedia.sanitizeName(inputName)):
|
nzbtomedia.sanitizeName(fileName) in nzbtomedia.sanitizeName(inputName)):
|
||||||
foundFile = True
|
foundFile = True
|
||||||
logger.debug("Found file %s that matches Torrent Name %s" % (fullFileName, inputName))
|
logger.debug("Found file %s that matches Torrent Name %s" % (fullFileName, inputName))
|
||||||
|
|
|
@ -63,11 +63,10 @@ def makeDir(path):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
single = False
|
|
||||||
tordir = False
|
tordir = False
|
||||||
|
|
||||||
if inputDirectory is None: # =Nothing to process here.
|
if inputDirectory is None: # =Nothing to process here.
|
||||||
return inputDirectory, inputName, inputCategory, root, single
|
return inputDirectory, inputName, inputCategory, root
|
||||||
|
|
||||||
pathlist = os.path.normpath(inputDirectory).split(os.sep)
|
pathlist = os.path.normpath(inputDirectory).split(os.sep)
|
||||||
|
|
||||||
|
@ -79,9 +78,8 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
logger.debug("SEARCH: Could not find a category in the directory structure")
|
logger.debug("SEARCH: Could not find a category in the directory structure")
|
||||||
|
|
||||||
if not os.path.isdir(inputDirectory) and os.path.isfile(inputDirectory): # If the input directory is a file
|
if not os.path.isdir(inputDirectory) and os.path.isfile(inputDirectory): # If the input directory is a file
|
||||||
single = True
|
|
||||||
if not inputName: inputName = os.path.split(os.path.normpath(inputDirectory))[1]
|
if not inputName: inputName = os.path.split(os.path.normpath(inputDirectory))[1]
|
||||||
return inputDirectory, inputName, inputCategory, root, single
|
return inputDirectory, inputName, inputCategory, root
|
||||||
|
|
||||||
if inputCategory and os.path.isdir(os.path.join(inputDirectory, inputCategory)):
|
if inputCategory and os.path.isdir(os.path.join(inputDirectory, inputCategory)):
|
||||||
logger.info(
|
logger.info(
|
||||||
|
@ -93,12 +91,23 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
inputDirectory = os.path.join(inputDirectory, inputName)
|
inputDirectory = os.path.join(inputDirectory, inputName)
|
||||||
logger.info("SEARCH: Setting inputDirectory to %s" % (inputDirectory))
|
logger.info("SEARCH: Setting inputDirectory to %s" % (inputDirectory))
|
||||||
tordir = True
|
tordir = True
|
||||||
if inputName and os.path.isdir(os.path.join(inputDirectory, sanitizeName(inputName))):
|
elif inputName and os.path.isdir(os.path.join(inputDirectory, sanitizeName(inputName))):
|
||||||
logger.info("SEARCH: Found torrent directory %s in input directory directory %s" % (
|
logger.info("SEARCH: Found torrent directory %s in input directory directory %s" % (
|
||||||
sanitizeName(inputName), inputDirectory))
|
sanitizeName(inputName), inputDirectory))
|
||||||
inputDirectory = os.path.join(inputDirectory, sanitizeName(inputName))
|
inputDirectory = os.path.join(inputDirectory, sanitizeName(inputName))
|
||||||
logger.info("SEARCH: Setting inputDirectory to %s" % (inputDirectory))
|
logger.info("SEARCH: Setting inputDirectory to %s" % (inputDirectory))
|
||||||
tordir = True
|
tordir = True
|
||||||
|
elif inputName and os.path.isfile(os.path.join(inputDirectory, inputName)):
|
||||||
|
logger.info("SEARCH: Found torrent directory %s in input directory directory %s" % (inputName, inputDirectory))
|
||||||
|
inputDirectory = os.path.join(inputDirectory, inputName)
|
||||||
|
logger.info("SEARCH: Setting inputDirectory to %s" % (inputDirectory))
|
||||||
|
tordir = True
|
||||||
|
elif inputName and os.path.isfile(os.path.join(inputDirectory, sanitizeName(inputName))):
|
||||||
|
logger.info("SEARCH: Found torrent file %s in input directory directory %s" % (
|
||||||
|
sanitizeName(inputName), inputDirectory))
|
||||||
|
inputDirectory = os.path.join(inputDirectory, sanitizeName(inputName))
|
||||||
|
logger.info("SEARCH: Setting inputDirectory to %s" % (inputDirectory))
|
||||||
|
tordir = True
|
||||||
|
|
||||||
imdbid = [item for item in pathlist if '.cp(tt' in item] # This looks for the .cp(tt imdb id in the path.
|
imdbid = [item for item in pathlist if '.cp(tt' in item] # This looks for the .cp(tt imdb id in the path.
|
||||||
if imdbid and not '.cp(tt' in inputName:
|
if imdbid and not '.cp(tt' in inputName:
|
||||||
|
@ -128,7 +137,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
logger.info("SEARCH: Could not find a unique directory for this download. Assume a common directory.")
|
logger.info("SEARCH: Could not find a unique directory for this download. Assume a common directory.")
|
||||||
logger.info("SEARCH: We will try and determine which files to process, individually")
|
logger.info("SEARCH: We will try and determine which files to process, individually")
|
||||||
|
|
||||||
return inputDirectory, inputName, inputCategory, root, single
|
return inputDirectory, inputName, inputCategory, root
|
||||||
|
|
||||||
def getDirSize(inputPath):
|
def getDirSize(inputPath):
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
@ -654,10 +663,23 @@ def isMediaFile(mediafile, media=True, audio=True, meta=True, archives=True):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def listMediaFiles(path, minSize=0, delete_ignored=0, media=True, audio=True, meta=True, archives=True):
|
def listMediaFiles(path, minSize=0, delete_ignored=0, media=True, audio=True, meta=True, archives=True):
|
||||||
if not os.path.isdir(path):
|
|
||||||
return []
|
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
if os.path.isfile(path): # Single file downloads.
|
||||||
|
curFile = os.path.split(path)[1]
|
||||||
|
if isMediaFile(curFile, media, audio, meta, archives):
|
||||||
|
# Optionally ignore sample files
|
||||||
|
if is_sample(path) or not is_minSize(path, minSize):
|
||||||
|
if delete_ignored == 1:
|
||||||
|
try:
|
||||||
|
os.unlink(path)
|
||||||
|
logger.debug('Ignored file %s has been removed ...' % (curFile))
|
||||||
|
except:pass
|
||||||
|
else:
|
||||||
|
files.append(path)
|
||||||
|
|
||||||
|
return files
|
||||||
|
|
||||||
for curFile in os.listdir(path):
|
for curFile in os.listdir(path):
|
||||||
fullCurFile = os.path.join(path, curFile)
|
fullCurFile = os.path.join(path, curFile)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue