mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
fix remote_Dri for HeadPhones. Fixes #499 Fix encoding on manual scan.
This commit is contained in:
parent
8540d40cb1
commit
c048c03aa5
5 changed files with 62 additions and 13 deletions
|
@ -40,11 +40,16 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
inputDirectory, inputName, inputCategory, root = 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
|
||||||
|
|
||||||
if inputCategory == "":
|
if inputCategory == "":
|
||||||
inputCategory = "UNCAT"
|
inputCategory = "UNCAT"
|
||||||
|
|
||||||
usercat = inputCategory
|
usercat = inputCategory
|
||||||
|
try:
|
||||||
|
inputName = inputName.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
try:
|
||||||
|
inputDirectory = inputDirectory.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
logger.debug("Determined Directory: %s | Name: %s | Category: %s" % (inputDirectory, inputName, inputCategory))
|
logger.debug("Determined Directory: %s | Name: %s | Category: %s" % (inputDirectory, inputName, inputCategory))
|
||||||
|
|
||||||
|
@ -98,6 +103,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
else:
|
else:
|
||||||
outputDestination = os.path.normpath(
|
outputDestination = os.path.normpath(
|
||||||
nzbtomedia.os.path.join(nzbtomedia.OUTPUTDIRECTORY, inputCategory))
|
nzbtomedia.os.path.join(nzbtomedia.OUTPUTDIRECTORY, inputCategory))
|
||||||
|
try:
|
||||||
|
outputDestination = outputDestination.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
logger.info("Output directory set to: %s" % (outputDestination))
|
logger.info("Output directory set to: %s" % (outputDestination))
|
||||||
|
|
||||||
|
@ -129,7 +137,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
nzbtomedia.os.path.join(outputDestination, os.path.basename(filePath)), fullFileName)
|
nzbtomedia.os.path.join(outputDestination, os.path.basename(filePath)), fullFileName)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Setting outputDestination to %s to preserve folder structure" % (os.path.dirname(targetFile)))
|
"Setting outputDestination to %s to preserve folder structure" % (os.path.dirname(targetFile)))
|
||||||
|
try:
|
||||||
|
targetFile = targetFile.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
if root == 1:
|
if root == 1:
|
||||||
if not foundFile:
|
if not foundFile:
|
||||||
logger.debug("Looking for %s in: %s" % (inputName, inputFile))
|
logger.debug("Looking for %s in: %s" % (inputName, inputFile))
|
||||||
|
@ -286,7 +296,15 @@ def main(args):
|
||||||
if clientAgent.lower() not in nzbtomedia.TORRENT_CLIENTS and clientAgent != 'manual':
|
if clientAgent.lower() not in nzbtomedia.TORRENT_CLIENTS and clientAgent != 'manual':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
results = processTorrent(dirName, os.path.basename(dirName), subsection, inputHash, inputID,
|
try:
|
||||||
|
dirName = dirName.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
inputName = os.path.basename(dirName)
|
||||||
|
try:
|
||||||
|
inputName = inputName.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
results = processTorrent(dirName, inputName, subsection, inputHash, inputID,
|
||||||
clientAgent)
|
clientAgent)
|
||||||
if results[0] != 0:
|
if results[0] != 0:
|
||||||
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
|
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
|
||||||
|
|
|
@ -727,7 +727,15 @@ def main(args, section=None):
|
||||||
if clientAgent.lower() not in nzbtomedia.NZB_CLIENTS and clientAgent != 'manual':
|
if clientAgent.lower() not in nzbtomedia.NZB_CLIENTS and clientAgent != 'manual':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent,
|
try:
|
||||||
|
dirName = dirName.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
inputName = os.path.basename(dirName)
|
||||||
|
try:
|
||||||
|
inputName = inputName.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
results = process(dirName, inputName, 0, clientAgent=clientAgent,
|
||||||
download_id=download_id, inputCategory=subsection)
|
download_id=download_id, inputCategory=subsection)
|
||||||
if results[0] != 0:
|
if results[0] != 0:
|
||||||
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
|
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
|
||||||
|
|
|
@ -94,7 +94,7 @@ class autoProcessMusic:
|
||||||
|
|
||||||
params['dir'] = os.path.dirname(dirName)
|
params['dir'] = os.path.dirname(dirName)
|
||||||
if remote_path:
|
if remote_path:
|
||||||
params['dir'] = remoteDir(dirName)
|
params['dir'] = remoteDir(os.path.dirname(dirName))
|
||||||
|
|
||||||
release_status = self.get_status(url, apikey, dirName)
|
release_status = self.get_status(url, apikey, dirName)
|
||||||
if not release_status:
|
if not release_status:
|
||||||
|
|
|
@ -126,6 +126,9 @@ class autoProcessTV:
|
||||||
logger.info('Found corrupt videos. Setting status Failed')
|
logger.info('Found corrupt videos. Setting status Failed')
|
||||||
status = 1
|
status = 1
|
||||||
failed = 1
|
failed = 1
|
||||||
|
elif clientAgent == "manual" and not listMediaFiles(dirName, media=True, audio=False, meta=False, archives=True):
|
||||||
|
logger.warning("No media files found in directory %s to manually process." % (dirName), section)
|
||||||
|
return [0, ""] # Success (as far as this script is concerned)
|
||||||
|
|
||||||
if fork not in nzbtomedia.SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and nzbExtractionBy != "Destination"):
|
if fork not in nzbtomedia.SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and nzbExtractionBy != "Destination"):
|
||||||
if inputName:
|
if inputName:
|
||||||
|
|
|
@ -40,6 +40,9 @@ def sanitizeName(name):
|
||||||
|
|
||||||
# remove leading/trailing periods and spaces
|
# remove leading/trailing periods and spaces
|
||||||
name = name.strip(' .')
|
name = name.strip(' .')
|
||||||
|
try:
|
||||||
|
name = name.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -69,6 +72,13 @@ def remoteDir(path):
|
||||||
def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
tordir = False
|
tordir = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
inputName = inputName.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
try:
|
||||||
|
inputDirectory = inputDirectory.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
if inputDirectory is None: # =Nothing to process here.
|
if inputDirectory is None: # =Nothing to process here.
|
||||||
return inputDirectory, inputName, inputCategory, root
|
return inputDirectory, inputName, inputCategory, root
|
||||||
|
|
||||||
|
@ -518,6 +528,10 @@ def getDirs(section, subsection):
|
||||||
title = os.path.splitext(os.path.basename(mediafile))[0]
|
title = os.path.splitext(os.path.basename(mediafile))[0]
|
||||||
newPath = os.path.join(path, sanitizeName(title))
|
newPath = os.path.join(path, sanitizeName(title))
|
||||||
|
|
||||||
|
try:
|
||||||
|
newPath = newPath.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
# Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe).
|
# Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe).
|
||||||
if os.path.isfile(newPath):
|
if os.path.isfile(newPath):
|
||||||
newPath2 = os.path.join(os.path.join(os.path.split(newPath)[0], 'new'), os.path.split(newPath)[1])
|
newPath2 = os.path.join(os.path.join(os.path.split(newPath)[0], 'new'), os.path.split(newPath)[1])
|
||||||
|
@ -527,8 +541,13 @@ def getDirs(section, subsection):
|
||||||
if not os.path.exists(newPath):
|
if not os.path.exists(newPath):
|
||||||
makeDir(newPath)
|
makeDir(newPath)
|
||||||
|
|
||||||
|
newfile = os.path.join(newPath, sanitizeName(os.path.split(mediafile)[1]))
|
||||||
|
try:
|
||||||
|
newfile = newfile.encode(nzbtomedia.SYS_ENCODING)
|
||||||
|
except: pass
|
||||||
|
|
||||||
# link file to its new path
|
# link file to its new path
|
||||||
copy_link(mediafile, os.path.join(newPath, sanitizeName(os.path.split(mediafile)[1])), 'hard')
|
copy_link(mediafile, newfile, 'hard')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to move %s to its own directory: %s" % (os.path.split(mediafile)[1], e))
|
logger.error("Failed to move %s to its own directory: %s" % (os.path.split(mediafile)[1], e))
|
||||||
|
|
||||||
|
@ -548,12 +567,13 @@ def getDirs(section, subsection):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.CFG[section][subsection]["watch_dir"], e))
|
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.CFG[section][subsection]["watch_dir"], e))
|
||||||
|
|
||||||
try:
|
if nzbtomedia.USELINK == 'move':
|
||||||
outputDirectory = os.path.join(nzbtomedia.OUTPUTDIRECTORY, subsection)
|
try:
|
||||||
if os.path.exists(outputDirectory):
|
outputDirectory = os.path.join(nzbtomedia.OUTPUTDIRECTORY, subsection)
|
||||||
to_return.extend(processDir(outputDirectory))
|
if os.path.exists(outputDirectory):
|
||||||
except Exception as e:
|
to_return.extend(processDir(outputDirectory))
|
||||||
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.OUTPUTDIRECTORY, e))
|
except Exception as e:
|
||||||
|
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.OUTPUTDIRECTORY, e))
|
||||||
|
|
||||||
if not to_return:
|
if not to_return:
|
||||||
logger.debug("No directories identified in %s:%s for post-processing" % (section,subsection))
|
logger.debug("No directories identified in %s:%s for post-processing" % (section,subsection))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue