Manual run handles non utf-8 characters.

This commit is contained in:
clinton-hall 2014-07-20 13:31:08 +09:30
commit 0aac86548a

View file

@ -483,10 +483,10 @@ def getDirs(section, subsection):
# search for single files and move them into their own folder for post-processing # search for single files and move them into their own folder for post-processing
for mediafile in [ os.path.join(path, o) for o in os.listdir(path) if for mediafile in [ os.path.join(path, o) for o in os.listdir(path) if
os.path.isfile(os.path.join(path, o)) ]: os.path.isfile(os.path.join(path, o)) ]:
logger.debug("Found file %s in root directory %s." % (mediafile, path)) try:
logger.debug("Found file %s in root directory %s." % (sanitizeName(os.path.split(mediafile)[1]), path))
newPath = None newPath = None
fileExt = os.path.splitext(os.path.basename(mediafile))[1] fileExt = os.path.splitext(os.path.basename(mediafile))[1]
try: try:
if fileExt in nzbtomedia.AUDIOCONTAINER: if fileExt in nzbtomedia.AUDIOCONTAINER:
f = beets.mediafile.MediaFile(mediafile) f = beets.mediafile.MediaFile(mediafile)
@ -512,7 +512,7 @@ def getDirs(section, subsection):
newPath = os.path.join(path, sanitizeName(title)) newPath = os.path.join(path, sanitizeName(title))
except Exception, e: except Exception, e:
logger.error("Exception parsing name for media file: %s: %s" % (mediafile, e)) logger.error("Exception parsing name for media file: %s: %s" % (sanitizeName(os.path.split(mediafile)[1]), e))
if not newPath: if not newPath:
title = os.path.splitext(os.path.basename(mediafile))[0] title = os.path.splitext(os.path.basename(mediafile))[0]
@ -529,6 +529,8 @@ def getDirs(section, subsection):
# move file to its new path # move file to its new path
copy_link(mediafile, os.path.join(newPath, os.path.split(mediafile)[1]), 'hard') copy_link(mediafile, os.path.join(newPath, os.path.split(mediafile)[1]), 'hard')
except:
logger.error("Failed to move %s to its own directory" % (sanitizeName(os.path.split(mediafile)[1])))
removeEmptyFolders(path, removeRoot=False) removeEmptyFolders(path, removeRoot=False)