mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Store: more formats for searches. Wordwrap tooltips.
This commit is contained in:
parent
b17ecef767
commit
364729d28f
@ -90,5 +90,6 @@ class ManyBooksStore(BasicStoreConfig, StorePlugin):
|
||||
s.price = price.strip()
|
||||
s.detail_item = '/titles/' + id
|
||||
s.drm = SearchResult.DRM_UNLOCKED
|
||||
s.formts = 'EPUB, PDB (eReader, PalmDoc, zTXT, Plucker, iSilo), FB2, ZIP, AZW, MOBI, PRC, LIT, PKG, PDF, TXT, RB, RTF, LRF, TCR, JAR'
|
||||
|
||||
yield s
|
||||
|
@ -104,8 +104,8 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
||||
for book_data in data.xpath('//ul/li'):
|
||||
book = BookRef()
|
||||
book.detail_item = ''.join(book_data.xpath('.//a/@href'))
|
||||
book.format = ''.join(book_data.xpath('.//i/text()'))
|
||||
book.format = book.format.strip()
|
||||
book.formats = ''.join(book_data.xpath('.//i/text()'))
|
||||
book.formats = book.formats.strip()
|
||||
|
||||
text = ''.join(book_data.xpath('.//a/text()'))
|
||||
if ':' in text:
|
||||
@ -222,7 +222,7 @@ class BooksModel(QAbstractItemModel):
|
||||
self.books = []
|
||||
if self.filter:
|
||||
for b in self.all_books:
|
||||
test = '%s %s %s' % (b.title, b.author, b.format)
|
||||
test = '%s %s %s' % (b.title, b.author, b.formats)
|
||||
test = test.lower()
|
||||
include = True
|
||||
for item in self.filter.split(' '):
|
||||
@ -275,7 +275,7 @@ class BooksModel(QAbstractItemModel):
|
||||
elif col == 1:
|
||||
return QVariant(result.author)
|
||||
elif col == 2:
|
||||
return QVariant(result.format)
|
||||
return QVariant(result.formats)
|
||||
return NONE
|
||||
|
||||
def data_as_text(self, result, col):
|
||||
@ -285,7 +285,7 @@ class BooksModel(QAbstractItemModel):
|
||||
elif col == 1:
|
||||
text = result.author
|
||||
elif col == 2:
|
||||
text = result.format
|
||||
text = result.formats
|
||||
return text
|
||||
|
||||
def sort(self, col, order, reset=True):
|
||||
|
@ -71,3 +71,12 @@ class OpenLibraryStore(BasicStoreConfig, StorePlugin):
|
||||
s.drm = SearchResult.DRM_UNKNOWN
|
||||
|
||||
yield s
|
||||
|
||||
def get_details(self, search_result, timeout):
|
||||
url = 'http://openlibrary.org/'
|
||||
|
||||
br = browser()
|
||||
with closing(br.open(url_slash_cleaner(url + search_result.detail_item), timeout=timeout)) as nf:
|
||||
idata = html.fromstring(nf.read())
|
||||
search_result.formats = ', '.join(list(set(idata.xpath('//a[contains(@title, "Download")]/text()'))))
|
||||
return True
|
||||
|
@ -559,22 +559,22 @@ class Matches(QAbstractItemModel):
|
||||
return QVariant(self.DRM_UNKNOWN_ICON)
|
||||
elif role == Qt.ToolTipRole:
|
||||
if col == 1:
|
||||
return QVariant(result.title)
|
||||
return QVariant('<p>%s</p>' % result.title)
|
||||
elif col == 2:
|
||||
return QVariant(result.author)
|
||||
return QVariant('<p>%s</p>' % result.author)
|
||||
elif col == 3:
|
||||
return QVariant(_('Detected price as: %s. Check with the store before making a purchase to verify this price information is correct.') % result.price)
|
||||
return QVariant('<p>' + _('Detected price as: %s. Check with the store before making a purchase to verify this price is correct. This price often does not include promotions the store may be running.') % result.price + '</p>')
|
||||
elif col == 4:
|
||||
if result.drm == SearchResult.DRM_LOCKED:
|
||||
return QVariant(_('This book as been detected as having DRM restrictions. This book may not work with your reader and you will have limitations placed upon you as to what you can do with this book. Check with the store before making any purchases to ensure you can actually read this book.'))
|
||||
return QVariant('<p>' + _('This book as been detected as having DRM restrictions. This book may not work with your reader and you will have limitations placed upon you as to what you can do with this book. Check with the store before making any purchases to ensure you can actually read this book.') + '</p>')
|
||||
elif result.drm == SearchResult.DRM_UNLOCKED:
|
||||
return QVariant(_('This book has been detected as being DRM Free. You should be able to use this book on any device provided it is in a format calibre supports for conversion. However, before making a purchase double check the DRM status with the store. The store may not be disclosing the use of DRM.'))
|
||||
return QVariant('<p>' + _('This book has been detected as being DRM Free. You should be able to use this book on any device provided it is in a format calibre supports for conversion. However, before making a purchase double check the DRM status with the store. The store may not be disclosing the use of DRM.') + '</p>')
|
||||
else:
|
||||
return QVariant(_('The DRM status of this book could not be determined. There is a very high likelihood that this book is actually DRM restricted.'))
|
||||
return QVariant('<p>' + _('The DRM status of this book could not be determined. There is a very high likelihood that this book is actually DRM restricted.') + '</p>')
|
||||
elif col == 5:
|
||||
return QVariant(result.store_name)
|
||||
return QVariant('<p>%s</p>' % result.store_name)
|
||||
elif col == 6:
|
||||
return QVariant(result.formats)
|
||||
return QVariant('<p>%s</p>' % result.formats)
|
||||
elif role == Qt.SizeHintRole:
|
||||
return QSize(64, 64)
|
||||
return NONE
|
||||
|
@ -93,3 +93,11 @@ class SmashwordsStore(BasicStoreConfig, StorePlugin):
|
||||
s.drm = SearchResult.DRM_UNLOCKED
|
||||
|
||||
yield s
|
||||
def get_details(self, search_result, timeout):
|
||||
url = 'http://www.smashwords.com/'
|
||||
|
||||
br = browser()
|
||||
with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
|
||||
idata = html.fromstring(nf.read())
|
||||
search_result.formats = ', '.join(list(set(idata.xpath('//td//b//text()'))))
|
||||
return True
|
||||
|
Loading…
x
Reference in New Issue
Block a user