From 7e7478be300086b9d5c6189bcfd17734e83bad69 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 27 May 2014 11:09:06 +0200 Subject: [PATCH] fix pdf info --- oml/item/models.py | 1 - oml/media/pdf.py | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/oml/item/models.py b/oml/item/models.py index dd91a44..dac80e2 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -270,7 +270,6 @@ class Item(db.Model): # get metadata from external resources self.scrape() - self.update() self.update_icons() self.modified = datetime.utcnow() self.save() diff --git a/oml/media/pdf.py b/oml/media/pdf.py index 00f953c..cde5c7c 100644 --- a/oml/media/pdf.py +++ b/oml/media/pdf.py @@ -139,8 +139,7 @@ def info(pdf): if stdnum.isbn.is_valid(value): data['isbn'] = [value] del data['identifier'] - - for key, value in data: + for key, value in data.iteritems(): if isinstance(value, dict): value = ' '.join(value.values()) data[key] = value @@ -151,6 +150,11 @@ def info(pdf): isbn = extract_isbn(text) if isbn: data['isbn'] = [isbn] + if 'isbn' in data and isinstance(data['isbn'], basestring): + data['isbn'] = [data['isbn']] + if 'date' in data and len(data['date']) == 8 and data['date'].isdigit(): + d = data['date'] + data['date'] = '%s-%s-%s' % (d[:4], d[4:6], d[6:]) return data '''