better path, fixes #81 and fixes #25

This commit is contained in:
j 2016-01-07 00:59:06 +05:30
parent d04636bf69
commit 7ca90dedfc
1 changed files with 11 additions and 1 deletions

View File

@ -586,11 +586,21 @@ class File(db.Model):
title = format_underscores(title)
author = format_underscores(author)
publisher = j.get('publisher')
if publisher:
extra = ', '.join(publisher)
else:
extra = ''
date = j.get('date')
if date and len(date) >= 4:
extra += ' ' + date[:4]
if extra:
title = '%s (%s)' % (title, extra.strip())
filename = '%s.%s' % (title, extension)
first = unicodedata.normalize('NFD', author[0].upper())[0].upper()
new_path = os.path.join(first, author, filename)
new_path = new_path.replace('\x00', '')
new_path = ox.decode_html(new_path)
if self.path == new_path:
return
h = ''