test for unknown extensions earlier, so those files don't become part of item_files and don't get canonizalized

This commit is contained in:
rolux 2012-09-11 18:44:32 +02:00
parent b923b176fd
commit 753ae2e6af
2 changed files with 11 additions and 10 deletions

19
pandoraclient Normal file → Executable file
View file

@ -109,16 +109,20 @@ def organize():
if not file['hash'] in files_by_hash:
files_by_hash[file['hash']] = []
files_by_hash[file['hash']].append(file)
# unexpected files
# unexpected files, unknown extensions
length = len(path.split('/'))
if length < 4:
issues['unexpected files'].append(path)
elif length == 4:
# add parsed title to item key so that episodes are their own item
key = '%s/%s' % ('/'.join(file['normalizedPath'].split('/')[:-1]), file['title'])
if not key in files_by_item:
files_by_item[key] = []
files_by_item[key].append(file)
# unknown extensions
if not file['type']:
issues['unknown extensions'].append(path)
else:
# add parsed title to item key so that episodes are their own item
key = '%s/%s' % ('/'.join(file['normalizedPath'].split('/')[:-1]), file['title'])
if not key in files_by_item:
files_by_item[key] = []
files_by_item[key].append(file)
if not dirnames and (not filenames or not filter(lambda x: not is_system_file(x), filenames)):
issues['empty directories'].append(relative_path)
@ -130,8 +134,6 @@ def organize():
print 'Scanning for inconsistencies'
for key in sorted(files_by_item.keys()):
item_files = files_by_item[key]
# unknown extensions
issues['unknown extensions'] += [file['path'] for file in item_files if not file['type']]
# missing video, missing subtitles, multiple versions
versions = ox.movie.parse_item_files(item_files)
main_files = sum([version['files'] for version in versions if version['isMainVersion']], [])
@ -304,7 +306,6 @@ def execute_organize():
source = paths[1] + '.pandora'
target = paths[1]
try:
print
rename_file(source, target)
except IOError as error:
print "Could not rename '%s' to '%s' (%s)" % (source, target, error)

View file

@ -6,6 +6,6 @@
"url": "https://0xdb.org/api/",
"username": "",
"volumes": {
"cinema": "/Users/rolux/Movies/Cinema/"
"cinema": "/Volumes/rolux/Movies/Cinema/"
}
}