From 2482845430a0722e1eeaaecd126ffcdc27670738 Mon Sep 17 00:00:00 2001 From: Christopher Hackett Date: Thu, 25 Nov 2021 17:48:37 +0000 Subject: [PATCH] Stores: Remove WH Smith UK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Searches return 0 results. On inspection eBooks no longer appear to be sold by WH Smith. Instead product pages for books on WH Smith contain text such as "Also available on eBook for £xx.xx. Click here to purchase from Rakuten Kobo" with a deep link to the relevant kobo.com product page. Additionally the landing page of Kobo on WH Smith also just links to Kobo.com. As such it seems wise to delist this store. --- src/calibre/customize/builtins.py | 11 --- .../gui2/store/stores/whsmith_uk_plugin.py | 78 ------------------- 2 files changed, 89 deletions(-) delete mode 100644 src/calibre/gui2/store/stores/whsmith_uk_plugin.py diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 12690e3a35..3d3d5ea909 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1811,16 +1811,6 @@ class StoreWeightlessBooksStore(StoreBase): formats = ['EPUB', 'HTML', 'LIT', 'MOBI', 'PDF'] -class StoreWHSmithUKStore(StoreBase): - name = 'WH Smith UK' - author = 'Charles Haley' - description = "Shop for savings on Books, discounted Magazine subscriptions and great prices on Stationery, Toys & Games" - actual_plugin = 'calibre.gui2.store.stores.whsmith_uk_plugin:WHSmithUKStore' - - headquarters = 'UK' - formats = ['EPUB', 'PDF'] - - class StoreWolneLekturyStore(StoreBase): name = 'Wolne Lektury' author = 'Tomasz Długosz' @@ -1893,7 +1883,6 @@ plugins += [ StoreSwiatEbookowStore, StoreVirtualoStore, StoreWeightlessBooksStore, - StoreWHSmithUKStore, StoreWolneLekturyStore, StoreWoblinkStore, XinXiiStore diff --git a/src/calibre/gui2/store/stores/whsmith_uk_plugin.py b/src/calibre/gui2/store/stores/whsmith_uk_plugin.py deleted file mode 100644 index e22ce6e6f2..0000000000 --- a/src/calibre/gui2/store/stores/whsmith_uk_plugin.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -store_version = 2 # Needed for dynamic plugin loading - -__license__ = 'GPL 3' -__copyright__ = '2011, John Schember ' -__docformat__ = 'restructuredtext en' - -from contextlib import closing -try: - from urllib.parse import quote -except ImportError: - from urllib import quote - -from lxml import html - -from qt.core import QUrl - -from calibre import browser -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 WHSmithUKStore(BasicStoreConfig, StorePlugin): - - def open(self, parent=None, detail_item=None, external=False): - url = 'https://www.whsmith.co.uk/' - url_details = '' - - if external or self.config.get('open_external', False): - if detail_item: - url = url_details + detail_item - open_url(QUrl(url)) - else: - detail_url = None - if detail_item: - detail_url = url_details + 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 = ('https://www.whsmith.co.uk/search?keywordCategoryId=wc_dept_ebooks&results=60' - '&page=1&keywords=' + quote(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('//li[@class="product"]'): - if counter <= 0: - break - id_ = ''.join(data.xpath('./a[@class="product_image_wrap"]/@href')) - if not id_: - continue - id_ = 'https://www.whsmith.co.uk' + id_ - cover_url = ''.join(data.xpath('.//img[@class="product_image"]/@src')) - title = ''.join(data.xpath('.//h4[@class="product_title"]/text()')) - author = ', '.join(data.xpath('.//span[@class="product_second"]/text()')) - price = ''.join(data.xpath('.//span[@class="price"]/text()')) - counter -= 1 - - s = SearchResult() - s.cover_url = cover_url - s.title = title.strip() - s.author = author.strip() - s.price = price - s.drm = SearchResult.DRM_LOCKED - s.detail_item = id_ - s.formats = 'ePub' - - yield s