mirror of
https://github.com/nikdoof/tvorganise.git
synced 2026-01-31 01:58:20 +00:00
Moved finding files into find_files function
This commit is contained in:
@@ -207,19 +207,28 @@ class Episode:
|
||||
#end Episode
|
||||
|
||||
|
||||
###################################
|
||||
# Find all valid files
|
||||
###################################
|
||||
allfiles=[]
|
||||
for (path,dirs,files) in os.walk(loc):
|
||||
def find_files(loc):
|
||||
"""Recursivly finds files in a directory
|
||||
"""
|
||||
allfiles=[]
|
||||
for (path,dirs,files) in os.walk(loc):
|
||||
for file in files:
|
||||
filename = os.path.join(os.path.abspath(path), file)
|
||||
allfiles.append( str(filename) )
|
||||
#end for f
|
||||
return allfiles
|
||||
#end find_files
|
||||
|
||||
# Strip out dotfiles/folder.jpg
|
||||
decrappified = []
|
||||
for current_file in allfiles:
|
||||
|
||||
|
||||
def main():
|
||||
###################################
|
||||
# Find all valid files
|
||||
###################################
|
||||
allfiles = find_files(loc)
|
||||
|
||||
# Strip out dotfiles/folder.jpg
|
||||
decrappified = []
|
||||
for current_file in allfiles:
|
||||
current_file_path,current_file_name = os.path.split(current_file)
|
||||
crappy = False
|
||||
for cur_decrap in tv_regex['decrappify']:
|
||||
@@ -227,22 +236,22 @@ for current_file in allfiles:
|
||||
crappy = True
|
||||
break
|
||||
if not crappy: decrappified.append(current_file)
|
||||
#end for current_file
|
||||
allfiles = decrappified
|
||||
#end for current_file
|
||||
allfiles = decrappified
|
||||
|
||||
# Warn if no files are found, then exit
|
||||
if len(allfiles) == 0:
|
||||
# Warn if no files are found, then exit
|
||||
if len(allfiles) == 0:
|
||||
print colour('No files found','red')
|
||||
sys.exit(1)
|
||||
|
||||
###################################
|
||||
# Validate filenames
|
||||
###################################
|
||||
###################################
|
||||
# Validate filenames
|
||||
###################################
|
||||
|
||||
valid = []
|
||||
invalid = []
|
||||
valid = []
|
||||
invalid = []
|
||||
|
||||
for cur in allfiles:
|
||||
for cur in allfiles:
|
||||
cpath,cfile = os.path.split(cur)
|
||||
cfile,cext = os.path.splitext(cfile)
|
||||
|
||||
@@ -280,12 +289,12 @@ for cur in allfiles:
|
||||
'cext':cext})
|
||||
#end for cur_checker
|
||||
#end for cur_checker
|
||||
#end for
|
||||
#end for
|
||||
|
||||
###################################
|
||||
# Show invalid names
|
||||
###################################
|
||||
if len(invalid) > 0:
|
||||
###################################
|
||||
# Show invalid names
|
||||
###################################
|
||||
if len(invalid) > 0:
|
||||
print colour('WARNING', 'red'), ': Invalid file-names found'
|
||||
|
||||
for errorno,errordescr in errors.items():
|
||||
@@ -301,10 +310,10 @@ if len(invalid) > 0:
|
||||
cur_path = os.path.join(c['path'], c['filename'] + c['cext'])
|
||||
print cur_path
|
||||
|
||||
###################################
|
||||
# Show valid names
|
||||
###################################
|
||||
if len(valid) > 0:
|
||||
###################################
|
||||
# Show valid names
|
||||
###################################
|
||||
if len(valid) > 0:
|
||||
print colour('INFO','green'), ': Valid file-names found:'
|
||||
allepisodes = ShowContainer()
|
||||
|
||||
@@ -318,3 +327,6 @@ if len(valid) > 0:
|
||||
allepisodes[showname][seasno][epno]['name'] = title
|
||||
#end for cur in valid
|
||||
print allepisodes
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user