fix remote_Dri for HeadPhones. Fixes #499 Fix encoding on manual scan.

This commit is contained in:
clinton-hall 2014-07-23 11:35:32 +09:30
commit c048c03aa5
5 changed files with 62 additions and 13 deletions

View file

@ -40,11 +40,16 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
inputDirectory, inputName, inputCategory, root = nzbtomedia.category_search(inputDirectory, inputName,
inputCategory, root,
nzbtomedia.CATEGORIES) # Confirm the category by parsing directory structure
if inputCategory == "":
inputCategory = "UNCAT"
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))
@ -98,6 +103,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
else:
outputDestination = os.path.normpath(
nzbtomedia.os.path.join(nzbtomedia.OUTPUTDIRECTORY, inputCategory))
try:
outputDestination = outputDestination.encode(nzbtomedia.SYS_ENCODING)
except: pass
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)
logger.debug(
"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 not foundFile:
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':
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)
if results[0] != 0:
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (

View file

@ -727,7 +727,15 @@ def main(args, section=None):
if clientAgent.lower() not in nzbtomedia.NZB_CLIENTS and clientAgent != 'manual':
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)
if results[0] != 0:
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (

View file

@ -94,7 +94,7 @@ class autoProcessMusic:
params['dir'] = os.path.dirname(dirName)
if remote_path:
params['dir'] = remoteDir(dirName)
params['dir'] = remoteDir(os.path.dirname(dirName))
release_status = self.get_status(url, apikey, dirName)
if not release_status:

View file

@ -126,6 +126,9 @@ class autoProcessTV:
logger.info('Found corrupt videos. Setting status Failed')
status = 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 inputName:

View file

@ -40,6 +40,9 @@ def sanitizeName(name):
# remove leading/trailing periods and spaces
name = name.strip(' .')
try:
name = name.encode(nzbtomedia.SYS_ENCODING)
except: pass
return name
@ -69,6 +72,13 @@ def remoteDir(path):
def category_search(inputDirectory, inputName, inputCategory, root, categories):
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.
return inputDirectory, inputName, inputCategory, root
@ -518,6 +528,10 @@ def getDirs(section, subsection):
title = os.path.splitext(os.path.basename(mediafile))[0]
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).
if os.path.isfile(newPath):
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):
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
copy_link(mediafile, os.path.join(newPath, sanitizeName(os.path.split(mediafile)[1])), 'hard')
copy_link(mediafile, newfile, 'hard')
except Exception as 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:
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.CFG[section][subsection]["watch_dir"], e))
try:
outputDirectory = os.path.join(nzbtomedia.OUTPUTDIRECTORY, subsection)
if os.path.exists(outputDirectory):
to_return.extend(processDir(outputDirectory))
except Exception as e:
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.OUTPUTDIRECTORY, e))
if nzbtomedia.USELINK == 'move':
try:
outputDirectory = os.path.join(nzbtomedia.OUTPUTDIRECTORY, subsection)
if os.path.exists(outputDirectory):
to_return.extend(processDir(outputDirectory))
except Exception as e:
logger.error("Failed to add directories from %s for post-processing: %s" % (nzbtomedia.OUTPUTDIRECTORY, e))
if not to_return:
logger.debug("No directories identified in %s:%s for post-processing" % (section,subsection))