better filenames

This commit is contained in:
j 2016-01-14 13:24:34 +05:30
parent db8a3f2689
commit 82d11e412f
1 changed files with 3 additions and 0 deletions

View File

@ -576,6 +576,8 @@ class File(db.Model):
author = '; '.join([get_sort_name(a) for a in j.get('author', [])])
if not author:
author = 'Unknown Author'
if ' (Ed.)' in author:
author = author.replace(' (Ed.)', '') + ' (Ed.)'
title = j.get('title', 'Untitled')
extension = j['extension']
@ -593,6 +595,7 @@ class File(db.Model):
if date and len(date) >= 4:
extra += ' ' + date[:4]
if extra:
extra = format_underscores(extra)
title = '%s (%s)' % (title, extra.strip())
filename = '%s.%s' % (title, extension)
first = unicodedata.normalize('NFD', author[0].upper())[0].upper()