mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
convert all listdir functions to unicode. Fixes #1189
This commit is contained in:
parent
868c8c36bf
commit
a7fcb7be9e
2 changed files with 12 additions and 12 deletions
|
@ -195,7 +195,7 @@ def getDirSize(inputPath):
|
||||||
from functools import partial
|
from functools import partial
|
||||||
prepend = partial(os.path.join, inputPath)
|
prepend = partial(os.path.join, inputPath)
|
||||||
return sum(
|
return sum(
|
||||||
[(os.path.getsize(f) if os.path.isfile(f) else getDirSize(f)) for f in map(prepend, os.listdir(inputPath))])
|
[(os.path.getsize(f) if os.path.isfile(f) else getDirSize(f)) for f in map(prepend, os.listdir(unicode(inputPath)))])
|
||||||
|
|
||||||
|
|
||||||
def is_minSize(inputName, minSize):
|
def is_minSize(inputName, minSize):
|
||||||
|
@ -322,7 +322,7 @@ def removeEmptyFolders(path, removeRoot=True):
|
||||||
|
|
||||||
# remove empty subfolders
|
# remove empty subfolders
|
||||||
logger.debug("Checking for empty folders in:{0}".format(path))
|
logger.debug("Checking for empty folders in:{0}".format(path))
|
||||||
files = os.listdir(path)
|
files = os.listdir(unicode(path))
|
||||||
if len(files):
|
if len(files):
|
||||||
for f in files:
|
for f in files:
|
||||||
fullpath = os.path.join(path, f)
|
fullpath = os.path.join(path, f)
|
||||||
|
@ -330,7 +330,7 @@ def removeEmptyFolders(path, removeRoot=True):
|
||||||
removeEmptyFolders(fullpath)
|
removeEmptyFolders(fullpath)
|
||||||
|
|
||||||
# if folder empty, delete it
|
# if folder empty, delete it
|
||||||
files = os.listdir(path)
|
files = os.listdir(unicode(path))
|
||||||
if len(files) == 0 and removeRoot:
|
if len(files) == 0 and removeRoot:
|
||||||
logger.debug("Removing empty folder:{}".format(path))
|
logger.debug("Removing empty folder:{}".format(path))
|
||||||
os.rmdir(path)
|
os.rmdir(path)
|
||||||
|
@ -607,9 +607,9 @@ def getDirs(section, subsection, link='hard'):
|
||||||
folders = []
|
folders = []
|
||||||
|
|
||||||
logger.info("Searching {0} for mediafiles to post-process ...".format(path))
|
logger.info("Searching {0} for mediafiles to post-process ...".format(path))
|
||||||
sync = [o for o in os.listdir(path) if os.path.splitext(o)[1] in ['.!sync', '.bts']]
|
sync = [o for o in os.listdir(unicode(path)) if os.path.splitext(o)[1] in ['.!sync', '.bts']]
|
||||||
# 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(unicode(path)) if
|
||||||
os.path.isfile(os.path.join(path, o))]:
|
os.path.isfile(os.path.join(path, o))]:
|
||||||
if len(sync) > 0:
|
if len(sync) > 0:
|
||||||
break
|
break
|
||||||
|
@ -673,11 +673,11 @@ def getDirs(section, subsection, link='hard'):
|
||||||
|
|
||||||
# removeEmptyFolders(path, removeRoot=False)
|
# removeEmptyFolders(path, removeRoot=False)
|
||||||
|
|
||||||
if os.listdir(path):
|
if os.listdir(unicode(path)):
|
||||||
for dir in [os.path.join(path, o) for o in os.listdir(path) if
|
for dir in [os.path.join(path, o) for o in os.listdir(unicode(path)) if
|
||||||
os.path.isdir(os.path.join(path, o))]:
|
os.path.isdir(os.path.join(path, o))]:
|
||||||
sync = [o for o in os.listdir(dir) if os.path.splitext(o)[1] in ['.!sync', '.bts']]
|
sync = [o for o in os.listdir(unicode(dir)) if os.path.splitext(o)[1] in ['.!sync', '.bts']]
|
||||||
if len(sync) > 0 or len(os.listdir(dir)) == 0:
|
if len(sync) > 0 or len(os.listdir(unicode(dir))) == 0:
|
||||||
continue
|
continue
|
||||||
folders.extend([dir])
|
folders.extend([dir])
|
||||||
return folders
|
return folders
|
||||||
|
@ -994,7 +994,7 @@ def listMediaFiles(path, minSize=0, delete_ignored=0, media=True, audio=True, me
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
for curFile in os.listdir(path):
|
for curFile in os.listdir(unicode(path)):
|
||||||
fullCurFile = os.path.join(path, curFile)
|
fullCurFile = os.path.join(path, curFile)
|
||||||
|
|
||||||
# if it's a folder do it recursively
|
# if it's a folder do it recursively
|
||||||
|
@ -1031,7 +1031,7 @@ def find_imdbid(dirName, inputName):
|
||||||
logger.info("Found imdbID [{0}]".format(imdbid))
|
logger.info("Found imdbID [{0}]".format(imdbid))
|
||||||
return imdbid
|
return imdbid
|
||||||
if os.path.isdir(dirName):
|
if os.path.isdir(dirName):
|
||||||
for file in os.listdir(dirName):
|
for file in os.listdir(unicode(dirName)):
|
||||||
m = re.search('(tt\d{7})', file)
|
m = re.search('(tt\d{7})', file)
|
||||||
if m:
|
if m:
|
||||||
imdbid = m.group(1)
|
imdbid = m.group(1)
|
||||||
|
|
|
@ -814,7 +814,7 @@ def Transcode_directory(dirName):
|
||||||
os.unlink(file)
|
os.unlink(file)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not os.listdir(newDir): # this is an empty directory and we didn't transcode into it.
|
if not os.listdir(unicode(newDir)): # this is an empty directory and we didn't transcode into it.
|
||||||
os.rmdir(newDir)
|
os.rmdir(newDir)
|
||||||
newDir = dirName
|
newDir = dirName
|
||||||
if not core.PROCESSOUTPUT and core.DUPLICATE: # We postprocess the original files to CP/SB
|
if not core.PROCESSOUTPUT and core.DUPLICATE: # We postprocess the original files to CP/SB
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue