additional extension rename checks. fixes #351

This commit is contained in:
clinton-hall 2014-05-02 10:15:37 +09:30
commit 03c3a013ff
2 changed files with 17 additions and 0 deletions

View file

@ -29,6 +29,8 @@ class autoProcessComics:
inputName, dirName = convert_to_ascii(inputName, dirName)
replaceExtensions(dirName)
params = {}
params['nzb_folder'] = dirName
if remote_path:

View file

@ -39,6 +39,21 @@ def sanitizeName(name):
return name
def replaceExtensions(path):
for dirpath, dirnames, filesnames in os.walk(path):
for filename in filesnames:
name, ext = os.path.splitext(filename)
if ext in nzbtomedia.EXT_REPLACE:
file = os.path.join(dirpath, filename)
target = os.path.join(dirpath, name + nzbtomedia.EXT_REPLACE[ext])
try:
logger.debug("Renaming %s to %s" % (file, target), 'RENAME')
shutil.move(file, target)
except:
logger.error("Could not rename %s to %s" % (file, target), 'RENAME')
else:
continue
def makeDir(path):
if not os.path.isdir(path):
try: