Conver ISBN into a WorldCat search url

This commit is contained in:
Kovid Goyal 2011-04-09 19:26:28 -06:00
parent a3e8c2560b
commit 2fbf0c7d13
3 changed files with 18 additions and 8 deletions

View File

@ -133,7 +133,7 @@ def to_metadata(browser, log, entry_, timeout): # {{{
default = utcnow().replace(day=15) default = utcnow().replace(day=15)
mi.pubdate = parse_date(pubdate, assume_utc=True, default=default) mi.pubdate = parse_date(pubdate, assume_utc=True, default=default)
except: except:
log.exception('Failed to parse pubdate') log.error('Failed to parse pubdate %r'%pubdate)
# Ratings # Ratings
for x in rating(extra): for x in rating(extra):

View File

@ -375,6 +375,10 @@ def urls_from_identifiers(identifiers): # {{{
ans.append((plugin.name, url)) ans.append((plugin.name, url))
except: except:
pass pass
isbn = identifiers.get('isbn', None)
if isbn:
ans.append(('ISBN',
'http://www.worldcat.org/search?q=bn%%3A%s&qt=advanced'%isbn))
return ans return ans
# }}} # }}}

View File

@ -46,9 +46,8 @@ class RichTextDelegate(QStyledItemDelegate): # {{{
def sizeHint(self, option, index): def sizeHint(self, option, index):
doc = self.to_doc(index) doc = self.to_doc(index)
ans = doc.size().toSize() ans = doc.size().toSize()
if ans.width() > 250: if ans.width() > 150:
doc.setTextWidth(250) ans.setWidth(160)
ans = doc.size().toSize()
ans.setHeight(ans.height()+10) ans.setHeight(ans.height()+10)
return ans return ans
@ -190,7 +189,7 @@ class ResultsModel(QAbstractTableModel): # {{{
elif col == 1: elif col == 1:
key = attrgetter('title') key = attrgetter('title')
elif col == 2: elif col == 2:
key = attrgetter('authors') key = attrgetter('pubdate')
elif col == 3: elif col == 3:
key = attrgetter('has_cached_cover_url') key = attrgetter('has_cached_cover_url')
elif key == 4: elif key == 4:
@ -561,16 +560,23 @@ class CoversModel(QAbstractListModel): # {{{
if v == row: if v == row:
return k return k
def cover_keygen(self, x):
pmap = x[2]
if pmap is None:
return 1
return pmap.width()*pmap.height()
def clear_failed(self): def clear_failed(self):
good = [] good = []
pmap = {} pmap = {}
for i, x in enumerate(self.covers): dcovers = sorted(self.covers[1:], key=self.cover_keygen, reverse=True)
for i, x in enumerate(self.covers[0:1] + dcovers):
if not x[-1]: if not x[-1]:
good.append(x) good.append(x)
if i > 0: if i > 0:
plugin = self.plugin_for_index(i) plugin = self.plugin_for_index(i)
pmap[plugin] = len(good) - 1 pmap[plugin] = len(good) - 1
good = [x for x in self.covers if not x[-1]]
self.covers = good self.covers = good
self.plugin_map = pmap self.plugin_map = pmap
self.reset() self.reset()
@ -871,5 +877,5 @@ if __name__ == '__main__':
#DEBUG_DIALOG = True #DEBUG_DIALOG = True
app = QApplication([]) app = QApplication([])
d = FullFetch(Log()) d = FullFetch(Log())
d.start(title='great gatsby', authors=['Fitzgerald']) d.start(title='jurassic', authors=['crichton'])