in parse_item_files, strip unneeded '.en' (if, per version and per subtitle extension, there is only one language=='en' file)
This commit is contained in:
parent
e1508f4068
commit
913c8f4c1b
1 changed files with 8 additions and 1 deletions
|
@ -57,10 +57,11 @@ def format_path(data, directory_key='director'):
|
||||||
parts.insert(-1, data['subdirectory'])
|
parts.insert(-1, data['subdirectory'])
|
||||||
return unicodedata.normalize('NFD', u'/'.join(parts))
|
return unicodedata.normalize('NFD', u'/'.join(parts))
|
||||||
|
|
||||||
|
|
||||||
def parse_item_files(files):
|
def parse_item_files(files):
|
||||||
# parses a list of file objects associated with one item (file objects
|
# parses a list of file objects associated with one item (file objects
|
||||||
# as returned by parse_path, but extended with 'path' and 'time')
|
# as returned by parse_path, but extended with 'path' and 'time')
|
||||||
|
# and returns a list of version objects (in case of english-only subtitles,
|
||||||
|
# version[i]['files'][j]['normalizedPath'] will be modified)
|
||||||
def get_file_key(file):
|
def get_file_key(file):
|
||||||
return '\n'.join([
|
return '\n'.join([
|
||||||
file['version'] or '',
|
file['version'] or '',
|
||||||
|
@ -152,6 +153,12 @@ def parse_item_files(files):
|
||||||
key = get_version_key(file, extension=False)
|
key = get_version_key(file, extension=False)
|
||||||
version_key = '%s%s' % (key, extension[key] if key in extension else '')
|
version_key = '%s%s' % (key, extension[key] if key in extension else '')
|
||||||
version_files[version_key] = (version_files[version_key] if version_key in version_files else []) + [file]
|
version_files[version_key] = (version_files[version_key] if version_key in version_files else []) + [file]
|
||||||
|
# remove unneeded '.en'
|
||||||
|
for version_key in version_files:
|
||||||
|
for extension in EXTENSIONS['subtitle']:
|
||||||
|
files = [file for file in version_files[version_key] if file['extension'] == extension]
|
||||||
|
if len(files) == 1 and files[0]['language'] == LANGUAGES[0]:
|
||||||
|
files[0]['normalizedPath'] = format_path(dict(files[0], **{'language': None}))
|
||||||
# return data
|
# return data
|
||||||
data = []
|
data = []
|
||||||
for version_key in version_files:
|
for version_key in version_files:
|
||||||
|
|
Loading…
Reference in a new issue