mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-13 23:02:16 +00:00
Get full path to file, rather than a realtive one. Decrappify files in less roundabout and problem-causing way (used to split dir/file name, then rejoin the filenames to the location, which breaks if there is sub-directories)
This commit is contained in:
@@ -49,24 +49,20 @@ def getError(invalid,errorno):
|
|||||||
allfiles=[]
|
allfiles=[]
|
||||||
for (path,dirs,files) in os.walk(loc):
|
for (path,dirs,files) in os.walk(loc):
|
||||||
for file in files:
|
for file in files:
|
||||||
filename = os.path.join(path,file)
|
filename = os.path.join(os.path.abspath(path),file)
|
||||||
allfiles.append( str(filename) )
|
allfiles.append( str(filename) )
|
||||||
#end for f
|
#end for f
|
||||||
|
|
||||||
files = [x for x in allfiles if os.path.isfile(x)] # only get files, not folders
|
|
||||||
|
|
||||||
# Strip out dotfiles/folder.jpg
|
# Strip out dotfiles/folder.jpg
|
||||||
for current_file in allfiles:
|
for current_file in allfiles:
|
||||||
current_file_path,current_file_name = os.path.split(current_file)
|
current_file_path,current_file_name = os.path.split(current_file)
|
||||||
for cur_decrap in film_regex['decrappify']:
|
for cur_decrap in film_regex['decrappify']:
|
||||||
if cur_decrap.match(current_file_name):
|
if cur_decrap.match(current_file_name):
|
||||||
files.remove(current_file)
|
allfiles.remove(current_file)
|
||||||
#end for file
|
#end for file
|
||||||
|
|
||||||
files = [os.path.join(loc,x) for x in files] # append path to file name
|
|
||||||
|
|
||||||
# Warn if no files are found, then exit
|
# Warn if no files are found, then exit
|
||||||
if files.__len__() == 0:
|
if allfiles.__len__() == 0:
|
||||||
print colour('No files found','red')
|
print colour('No files found','red')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@@ -83,7 +79,7 @@ errors = {
|
|||||||
valid = []
|
valid = []
|
||||||
invalid = []
|
invalid = []
|
||||||
|
|
||||||
for cur in files:
|
for cur in allfiles:
|
||||||
cpath,cfile = os.path.split(cur)
|
cpath,cfile = os.path.split(cur)
|
||||||
cfile,cext = os.path.splitext(cfile)
|
cfile,cext = os.path.splitext(cfile)
|
||||||
|
|
||||||
@@ -93,6 +89,7 @@ for cur in files:
|
|||||||
if check:
|
if check:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
print cpath, "doesnt match"
|
||||||
invalid.append({'errorno':3, 'path':cpath,'filename':cfile,
|
invalid.append({'errorno':3, 'path':cpath,'filename':cfile,
|
||||||
'cext':cext})
|
'cext':cext})
|
||||||
#end for cur_checker
|
#end for cur_checker
|
||||||
|
|||||||
@@ -104,9 +104,11 @@ film_regex['missing_year'] = [
|
|||||||
# Valid paths
|
# Valid paths
|
||||||
#
|
#
|
||||||
# ./
|
# ./
|
||||||
|
#
|
||||||
|
|
||||||
film_regex['valid_path'] = [
|
film_regex['valid_path'] = [
|
||||||
re.compile("/.$"),
|
re.compile(".*?/video/films$"),
|
||||||
|
re.compile(".*?/video/films/Short Films(/.*?)?")
|
||||||
]
|
]
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
|
|||||||
Reference in New Issue
Block a user