From 7ca90dedfc3a5e46ebf673608f56832c86ec9e81 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 7 Jan 2016 00:59:06 +0530 Subject: [PATCH] better path, fixes #81 and fixes #25 --- oml/item/models.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/oml/item/models.py b/oml/item/models.py index 16a735b..2d83304 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -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 = ''