From d96d4300c2882e6532c4d254e014fe61fde251f6 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 24 May 2014 23:21:03 +0200 Subject: [PATCH] dont download available books, parse worldcat covers --- oml/item/models.py | 4 +--- oml/meta/worldcat.py | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/oml/item/models.py b/oml/item/models.py index c4483be..e74bfc6 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -345,12 +345,10 @@ class Item(db.Model): def queue_download(self): u = state.user() - t = Transfer.get_or_create(self.id) if not u in self.users: + t = Transfer.get_or_create(self.id) logger.debug('queue %s for download', self.id) self.users.append(u) - else: - logger.debug('%s already queued for download? %s %s', self.id, t.progress, t.added) def save_file(self, content): u = state.user() diff --git a/oml/meta/worldcat.py b/oml/meta/worldcat.py index b46972e..0da4403 100644 --- a/oml/meta/worldcat.py +++ b/oml/meta/worldcat.py @@ -62,6 +62,12 @@ def lookup(id): data['isbn'] = [] if isbn not in data['isbn']: data['isbn'].append(isbn) + cover = doc.xpath('//img[@class="cover"]') + if cover: + data['cover'] = cover[0].attrib['src'] + if data['cover'].startswith('//'): + data['cover'] = 'http:' + data['cover'] + if 'author' in data: data['author'] = [data['author']] if 'title' in data: