diff --git a/src/libprs500/ebooks/metadata/isbndb.py b/src/libprs500/ebooks/metadata/isbndb.py
index a17954f3e8..265f327506 100644
--- a/src/libprs500/ebooks/metadata/isbndb.py
+++ b/src/libprs500/ebooks/metadata/isbndb.py
@@ -23,7 +23,7 @@ from libprs500 import setup_cli_handlers, OptionParser
from libprs500.ebooks.metadata import MetaInformation
from libprs500.ebooks.BeautifulSoup import BeautifulStoneSoup
-BASE_URL = 'http://isbndb.com/api/books.xml?access_key=%(key)s&page_number=1&results=subjects,authors&'
+BASE_URL = 'http://isbndb.com/api/books.xml?access_key=%(key)s&page_number=1&results=subjects,authors,texts&'
class ISBNDBError(Exception):
pass
@@ -56,6 +56,7 @@ def fetch_metadata(url, max=100, timeout=5.):
class ISBNDBMetadata(MetaInformation):
+
def __init__(self, book):
MetaInformation.__init__(self, None, [])
@@ -77,6 +78,11 @@ class ISBNDBMetadata(MetaInformation):
pass
self.publisher = book.find('publishertext').string
+ summ = book.find('summary')
+ if summ and hasattr(summ, 'string') and summ.string:
+ self.comments = 'SUMMARY:\n'+summ.string
+
+
def build_isbn(base_url, opts):
return base_url + 'index1=isbn&value1='+opts.isbn
diff --git a/src/libprs500/gui2/dialogs/fetch_metadata.py b/src/libprs500/gui2/dialogs/fetch_metadata.py
index d4d5e0251c..24ac42d116 100644
--- a/src/libprs500/gui2/dialogs/fetch_metadata.py
+++ b/src/libprs500/gui2/dialogs/fetch_metadata.py
@@ -30,6 +30,7 @@ class Matches(QAbstractTableModel):
def __init__(self, matches):
self.matches = matches
+ self.matches.sort(cmp=lambda b, a: cmp(len(a.comments if a.comments else ''), len(b.comments if b.comments else '')))
QAbstractTableModel.__init__(self)
def rowCount(self, *args):
@@ -53,6 +54,9 @@ class Matches(QAbstractTableModel):
else:
return QVariant(section+1)
+ def summary(self, row):
+ return self.matches[row].comments
+
def data(self, index, role):
row, col = index.row(), index.column()
if role == Qt.DisplayRole:
@@ -91,6 +95,16 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
self.title = title
self.author = author.strip()
self.publisher = publisher
+ self.previous_row = None
+
+
+
+ def show_summary(self, current, previous):
+ row = current.row()
+ if row != self.previous_row:
+ summ = self.model.summary(row)
+ self.summary.setText(summ if summ else '')
+ self.previous_row = row
def fetch_metadata(self):
key = str(self.key.text())
@@ -132,6 +146,8 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
self.model = Matches(books)
self.matches.setModel(self.model)
+ QObject.connect(self.matches.selectionModel(), SIGNAL('currentRowChanged(QModelIndex, QModelIndex)'),
+ self.show_summary)
self.model.reset()
self.matches.selectionModel().select(self.model.index(0, 0),
QItemSelectionModel.Select | QItemSelectionModel.Rows)
@@ -139,6 +155,7 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
self.fetch.setEnabled(True)
self.unsetCursor()
self.matches.resizeColumnsToContents()
+
def selected_book(self):
diff --git a/src/libprs500/gui2/dialogs/fetch_metadata.ui b/src/libprs500/gui2/dialogs/fetch_metadata.ui
index 391c585cd1..959fb18d89 100644
--- a/src/libprs500/gui2/dialogs/fetch_metadata.ui
+++ b/src/libprs500/gui2/dialogs/fetch_metadata.ui
@@ -9,7 +9,7 @@
0
0
830
- 622
+ 700
@@ -81,6 +81,12 @@
-
+
+
+ 0
+ 1
+
+
true
@@ -92,6 +98,9 @@
+ -
+
+
diff --git a/src/libprs500/gui2/dialogs/metadata_single.py b/src/libprs500/gui2/dialogs/metadata_single.py
index c59c6123c1..bc6f50d62e 100644
--- a/src/libprs500/gui2/dialogs/metadata_single.py
+++ b/src/libprs500/gui2/dialogs/metadata_single.py
@@ -287,6 +287,12 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
if book.author_sort: self.author_sort.setText(book.author_sort)
self.publisher.setText(book.publisher)
self.isbn.setText(book.isbn)
+ summ = book.comments
+ if summ:
+ prefix = qstring_to_unicode(self.comments.text())
+ if prefix:
+ prefix += '\n'
+ self.comments.setText(prefix + summ)
else:
error_dialog(self, 'Cannot fetch metadata', 'You must specify at least one of ISBN, Title, Authors or Publisher')