From 7b81784a083d2dc12dfb700ef611514ef3708bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Tue, 1 Dec 2020 21:03:29 +0100 Subject: [PATCH] nexto plugin: migrate to buybox --- src/calibre/gui2/store/stores/nexto_plugin.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/store/stores/nexto_plugin.py b/src/calibre/gui2/store/stores/nexto_plugin.py index a7f8e7811c..55c0a988a3 100644 --- a/src/calibre/gui2/store/stores/nexto_plugin.py +++ b/src/calibre/gui2/store/stores/nexto_plugin.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals -store_version = 4 # Needed for dynamic plugin loading +store_version = 5 # Needed for dynamic plugin loading __license__ = 'GPL 3' -__copyright__ = '2011-2016, Tomasz Długosz ' +__copyright__ = '2011-2020, Tomasz Długosz ' __docformat__ = 'restructuredtext en' import re @@ -26,24 +26,35 @@ from calibre.gui2.store.search_result import SearchResult from calibre.gui2.store.web_store_dialog import WebStoreDialog +def as_base64(data): + if not isinstance(data, bytes): + data = data.encode('utf-8') + ans = b64encode(data) + if isinstance(ans, bytes): + ans = ans.decode('ascii') + return ans + + class NextoStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): - pid = '155711' + aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/35/58/' + + url = 'http://www.nexto.pl/' + + aff_url = aff_root + as_base64(url) - url = 'http://www.nexto.pl/ebooki_c1015.xml' detail_url = None - if detail_item: book_id = re.search(r'p[0-9]*\.xml\Z', detail_item) book_id = book_id.group(0).replace('.xml','').replace('p','') if book_id: - detail_url = 'http://www.nexto.pl/rf/pr?p=' + book_id + '&pid=' + pid + detail_url = aff_root + as_base64('http://www.nexto.pl/rf/pr?p=' + book_id) if external or self.config.get('open_external', False): - open_url(QUrl(url_slash_cleaner(detail_url if detail_url else url))) + open_url(QUrl(url_slash_cleaner(detail_url if detail_url else aff_url))) else: - d = WebStoreDialog(self.gui, url, parent, detail_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_()