diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 4858b585ae..dcec4dbc6b 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1387,15 +1387,6 @@ class StoreOpenBooksStore(StoreBase): 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.' - actual_plugin = 'calibre.gui2.store.stores.open_library_plugin:OpenLibraryStore' - - drm_free_only = True - headquarters = 'US' - formats = ['DAISY', 'DJVU', 'EPUB', 'MOBI', 'PDF', 'TXT'] - class StoreOReillyStore(StoreBase): name = 'OReilly' description = u'Programming and tech ebooks from OReilly.' diff --git a/src/calibre/gui2/store/stores/open_library_plugin.py b/src/calibre/gui2/store/stores/open_library_plugin.py deleted file mode 100644 index b95f1bf930..0000000000 --- a/src/calibre/gui2/store/stores/open_library_plugin.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import (unicode_literals, division, absolute_import, print_function) - -__license__ = 'GPL 3' -__copyright__ = '2011, John Schember ' -__docformat__ = 'restructuredtext en' - -import urllib2 -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 OpenLibraryStore(BasicStoreConfig, StorePlugin): - - def open(self, parent=None, detail_item=None, external=False): - url = 'http://openlibrary.org/' - - if external or self.config.get('open_external', False): - if detail_item: - url = url + detail_item - open_url(QUrl(url_slash_cleaner(url))) - else: - detail_url = None - if detail_item: - detail_url = url + detail_item - d = WebStoreDialog(self.gui, url, parent, detail_url) - d.setWindowTitle(self.name) - d.set_tags(self.config.get('tags', '')) - d.exec_() - - def search(self, query, max_results=10, timeout=60): - url = 'http://openlibrary.org/search?q=' + urllib2.quote(query) + '&has_fulltext=true' - - br = browser() - - counter = max_results - with closing(br.open(url, timeout=timeout)) as f: - doc = html.fromstring(f.read()) - for data in doc.xpath('//div[@id="searchResults"]/ul[@id="siteSearch"]/li'): - if counter <= 0: - break - - # Don't include books that don't have downloadable files. - if not data.xpath('boolean(./span[@class="actions"]//span[@class="label" and contains(text(), "Read")])'): - continue - id = ''.join(data.xpath('./span[@class="bookcover"]/a/@href')) - if not id: - continue - cover_url = ''.join(data.xpath('./span[@class="bookcover"]/a/img/@src')) - - title = ''.join(data.xpath('.//h3[@class="booktitle"]/a[@class="results"]/text()')) - author = ''.join(data.xpath('.//span[@class="bookauthor"]/a/text()')) - price = '$0.00' - - counter -= 1 - - s = SearchResult() - s.cover_url = cover_url - s.title = title.strip() - s.author = author.strip() - s.price = price - s.detail_item = id.strip() - s.drm = SearchResult.DRM_UNLOCKED - - 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