From 2db0287724b05fe802df0defd1730ce4ae60f058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Thu, 7 Dec 2017 00:28:00 +0100 Subject: [PATCH 1/2] replace koobe.pl with their new store, swiatebookow.pl --- src/calibre/customize/builtins.py | 26 +++++++------- ...koobe_plugin.py => swiatebookow_plugin.py} | 35 +++++++++---------- 2 files changed, 29 insertions(+), 32 deletions(-) rename src/calibre/gui2/store/stores/{koobe_plugin.py => swiatebookow_plugin.py} (62%) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index f870de8cff..5540096f3b 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1638,18 +1638,6 @@ class StoreKoboStore(StoreBase): affiliate = True -class StoreKoobeStore(StoreBase): - name = 'Koobe' - author = u'Tomasz Długosz' - description = u'Księgarnia internetowa oferuje ebooki (książki elektroniczne) w postaci plików epub, mobi i pdf.' - actual_plugin = 'calibre.gui2.store.stores.koobe_plugin:KoobeStore' - - drm_free_only = True - headquarters = 'PL' - formats = ['EPUB', 'MOBI', 'PDF'] - affiliate = True - - class StoreLegimiStore(StoreBase): name = 'Legimi' author = u'Tomasz Długosz' @@ -1790,6 +1778,18 @@ class StoreSmashwordsStore(StoreBase): affiliate = True +class StoreSwiatEbookowStore(StoreBase): + name = 'Świat Ebooków' + author = u'Tomasz Długosz' + description = u'Ebooki maje tę zaletę, że są zawsze i wszędzie tam, gdzie tylko nas dopadnie ochota na czytanie.' + actual_plugin = 'calibre.gui2.store.stores.swiatebookow_plugin:SwiatEbookowStore' + + drm_free_only = True + headquarters = 'PL' + formats = ['EPUB', 'MOBI', 'PDF'] + affiliate = True + + class StoreVirtualoStore(StoreBase): name = 'Virtualo' author = u'Tomasz Długosz' @@ -1879,7 +1879,6 @@ plugins += [ StoreGoogleBooksStore, StoreGutenbergStore, StoreKoboStore, - StoreKoobeStore, StoreLegimiStore, StoreLibreDEStore, StoreLitResStore, @@ -1893,6 +1892,7 @@ plugins += [ StorePublioStore, StoreRW2010Store, StoreSmashwordsStore, + StoreSwiatEbookowStore, StoreVirtualoStore, StoreWeightlessBooksStore, StoreWHSmithUKStore, diff --git a/src/calibre/gui2/store/stores/koobe_plugin.py b/src/calibre/gui2/store/stores/swiatebookow_plugin.py similarity index 62% rename from src/calibre/gui2/store/stores/koobe_plugin.py rename to src/calibre/gui2/store/stores/swiatebookow_plugin.py index 62381a1d4a..c45ab0f91a 100644 --- a/src/calibre/gui2/store/stores/koobe_plugin.py +++ b/src/calibre/gui2/store/stores/swiatebookow_plugin.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) -store_version = 5 # Needed for dynamic plugin loading +store_version = 1 # Needed for dynamic plugin loading __license__ = 'GPL 3' -__copyright__ = '2013-2016, Tomasz Długosz ' +__copyright__ = '2017, Tomasz Długosz ' __docformat__ = 'restructuredtext en' import urllib @@ -23,12 +23,12 @@ from calibre.gui2.store.search_result import SearchResult from calibre.gui2.store.web_store_dialog import WebStoreDialog -class KoobeStore(BasicStoreConfig, StorePlugin): +class SwiatEbookowStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): - aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/15/58/' + aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/181/58/' - url = 'http://www.koobe.pl/' + url = 'https://www.swiatebookow.pl/' aff_url = aff_root + str(b64encode(url)) @@ -51,36 +51,33 @@ class KoobeStore(BasicStoreConfig, StorePlugin): counter = max_results while counter: - with closing(br.open('http://www.koobe.pl/s,p,' + str(page) + ',szukaj/fraza:' + urllib.quote(query), timeout=timeout)) as f: + with closing(br.open('https://www.swiatebookow.pl/ebooki/?q=' + urllib.quote(query) + '&page=' + str(page), timeout=timeout)) as f: doc = html.fromstring(f.read().decode('utf-8')) - for data in doc.xpath('//div[@class="seach_result"]/div[@class="result"]'): + for data in doc.xpath('//div[@class="category-item-container"]//div[@class="book-large"]'): if counter <= 0: break - id = ''.join(data.xpath('.//div[@class="cover"]/a/@href')) + id = ''.join(data.xpath('./a/@href')) if not id: continue - cover_url = ''.join(data.xpath('.//div[@class="cover"]/a/img/@src')) - price = ''.join(data.xpath('.//span[@class="current_price"]/text()')) - if not price: - price = ''.join(data.xpath('.//div[@class="book_promo_price"]/span/text()')) - title = ''.join(data.xpath('.//h2[@class="title"]/a/text()')) - author = ', '.join(data.xpath('.//h3[@class="book_author"]/a/text()')) - formats = ', '.join(data.xpath('.//div[@class="formats"]/div/div/@title')) + cover_url = ''.join(data.xpath('.//div[@class="cover-xs"]/img/@src')) + price = ''.join(data.xpath('.//span[@class="item-price"]/text()')+data.xpath('.//span[@class="sub-price"]/text()')) + title = ''.join(data.xpath('.//h3/text()')) + author = ', '.join(data.xpath('.//div[@class="details"]/p/a/text()')) counter -= 1 s = SearchResult() - s.cover_url = 'http://www.koobe.pl/' + cover_url + s.cover_url = 'https://www.swiatebookow.pl' + cover_url s.title = title.strip() s.author = author.strip() s.price = price - s.detail_item = 'http://www.koobe.pl' + id[1:] - s.formats = formats.upper() + s.detail_item = 'https://www.swiatebookow.pl' + id + # s.formats = formats.upper() s.drm = SearchResult.DRM_UNLOCKED yield s - if not doc.xpath('//div[@class="site_bottom"]//a[@class="right"]'): + if not doc.xpath('//div[@class="paging_bootstrap pagination"]//a[@class="next"]'): break page+=1 From 1c6a40d4b4bf5086c073d9dba39357f3c5135e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Thu, 7 Dec 2017 00:47:06 +0100 Subject: [PATCH 2/2] change affiliate links for publio --- src/calibre/gui2/store/stores/publio_plugin.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/store/stores/publio_plugin.py b/src/calibre/gui2/store/stores/publio_plugin.py index 2b0e9b7d41..c60c34200b 100644 --- a/src/calibre/gui2/store/stores/publio_plugin.py +++ b/src/calibre/gui2/store/stores/publio_plugin.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) -store_version = 7 # Needed for dynamic plugin loading +store_version = 8 # Needed for dynamic plugin loading __license__ = 'GPL 3' __copyright__ = '2012-2017, Tomasz Długosz ' __docformat__ = 'restructuredtext en' import urllib +from base64 import b64encode from contextlib import closing from lxml import html @@ -25,13 +26,19 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog class PublioStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): - google_analytics = '?utm_source=tdcalibre&utm_medium=calibre' - url = 'http://www.publio.pl/' + google_analytics + aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/29/58/' + url = 'http://www.publio.pl/' + + aff_url = aff_root + str(b64encode(url)) + + detail_url = None + if detail_item: + detail_url = aff_root + str(b64encode(detail_item)) if external or self.config.get('open_external', False): - open_url(QUrl(url_slash_cleaner((detail_item + google_analytics) if detail_item else url))) + open_url(QUrl(url_slash_cleaner(detail_url if detail_url else aff_url))) else: - d = WebStoreDialog(self.gui, url, parent, detail_item if detail_item else url) + d = WebStoreDialog(self.gui, url, parent, detail_url if detail_url else aff_url) d.setWindowTitle(self.name) d.set_tags(self.config.get('tags', '')) d.exec_()