diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index e3b7bef5d8..8305e32303 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1378,6 +1378,14 @@ class StoreNextoStore(StoreBase): formats = ['EPUB', 'PDF'] affiliate = True +class StoreOpenBooksStore(StoreBase): + name = 'Open Books' + description = u'Comprehensive listing of DRM free ebooks from a variety of sources provided by users of calibre.' + actual_plugin = 'calibre.gui2.store.open_books_plugin:OpenBooksStore' + + drm_free_only = True + headquarters = 'US' + class StoreOpenLibraryStore(StoreBase): name = 'Open Library' description = u'One web page for every book ever published. The goal is to be a true online library. Over 20 million records from a variety of large catalogs as well as single contributions, with more on the way.' @@ -1504,6 +1512,7 @@ plugins += [ StoreManyBooksStore, StoreMobileReadStore, StoreNextoStore, + StoreOpenBooksStore, StoreOpenLibraryStore, StoreOReillyStore, StorePragmaticBookshelfStore, diff --git a/src/calibre/gui2/store/config/chooser/models.py b/src/calibre/gui2/store/config/chooser/models.py index dbda367fae..d2c6bcd8d3 100644 --- a/src/calibre/gui2/store/config/chooser/models.py +++ b/src/calibre/gui2/store/config/chooser/models.py @@ -133,7 +133,7 @@ class Matches(QAbstractItemModel): return QVariant('

%s

' % result.description) elif col == 2: if result.drm_free_only: - return QVariant('

' + _('This store only distributes ebooks with DRM.') + '

') + return QVariant('

' + _('This store only distributes ebooks without DRM.') + '

') else: return QVariant('

' + _('This store distributes ebooks with DRM. It may have some titles without DRM, but you will need to check on a per title basis.') + '

') elif col == 3: diff --git a/src/calibre/gui2/store/declined.txt b/src/calibre/gui2/store/declined.txt index ada839662d..3e553f2dc8 100644 --- a/src/calibre/gui2/store/declined.txt +++ b/src/calibre/gui2/store/declined.txt @@ -1,9 +1,6 @@ This is a list of stores that objected, declined or asked not to be included in the store integration. -* Borders (http://www.borders.com/) -* Indigo (http://www.chapters.indigo.ca/) +* Borders (http://www.borders.com/). +* Indigo (http://www.chapters.indigo.ca/). * Libraria Rizzoli (http://libreriarizzoli.corriere.it/). - No reply with two attempts over 2 weeks -* WH Smith (http://www.whsmith.co.uk/) - Refused to permit signing up for the affiliate program \ No newline at end of file diff --git a/src/calibre/gui2/store/open_books_plugin.py b/src/calibre/gui2/store/open_books_plugin.py new file mode 100644 index 0000000000..2e6c438d9d --- /dev/null +++ b/src/calibre/gui2/store/open_books_plugin.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- + +from __future__ import (unicode_literals, division, absolute_import, print_function) + +__license__ = 'GPL 3' +__copyright__ = '2011, John Schember ' +__docformat__ = 'restructuredtext en' + +import urllib +from contextlib import closing + +from lxml import html + +from PyQt4.Qt import QUrl + +from calibre import browser, url_slash_cleaner +from calibre.gui2 import open_url +from calibre.gui2.store import StorePlugin +from calibre.gui2.store.basic_config import BasicStoreConfig +from calibre.gui2.store.search_result import SearchResult +from calibre.gui2.store.web_store_dialog import WebStoreDialog + +class OpenBooksStore(BasicStoreConfig, StorePlugin): + + def open(self, parent=None, detail_item=None, external=False): + url = 'http://drmfree.calibre-ebook.com/' + + if external or self.config.get('open_external', False): + open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url))) + else: + d = WebStoreDialog(self.gui, self.url, parent, detail_item) + d.setWindowTitle(self.name) + d.set_tags(self.config.get('tags', '')) + d.exec_() + + def search(self, query, max_results=10, timeout=60): + url = 'http://drmfree.calibre-ebook.com/search/?q=' + urllib.quote_plus(query) + + br = browser() + + counter = max_results + with closing(br.open(url, timeout=timeout)) as f: + doc = html.fromstring(f.read()) + for data in doc.xpath('//ul[@id="object_list"]//li'): + if counter <= 0: + break + + id = ''.join(data.xpath('.//div[@class="links"]/a[1]/@href')) + id = id.strip() + if not id: + continue + + cover_url = ''.join(data.xpath('.//div[@class="cover"]/img/@src')) + + price = ''.join(data.xpath('.//div[@class="price"]/text()')) + a, b, price = price.partition('Price:') + price = price.strip() + if not price: + continue + + title = ''.join(data.xpath('.//div/strong/text()')) + author = ''.join(data.xpath('.//div[@class="author"]//text()')) + author = author.partition('by')[-1] + + counter -= 1 + + s = SearchResult() + s.cover_url = cover_url + s.title = title.strip() + s.author = author.strip() + s.price = price.strip() + s.detail_item = id.strip() + s.drm = SearchResult.DRM_UNLOCKED + + yield s