From ee0c54d684e9daf679bdb1b073fce417595acf48 Mon Sep 17 00:00:00 2001 From: t3d Date: Thu, 8 Jan 2015 16:37:33 +0100 Subject: [PATCH] Ads4books in Empik store --- src/calibre/customize/builtins.py | 1 + src/calibre/gui2/store/stores/empik_plugin.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index e38f603371..8fc3cc55de 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1471,6 +1471,7 @@ class StoreEmpikStore(StoreBase): headquarters = 'PL' formats = ['EPUB', 'MOBI', 'PDF'] + affiliate = True class StoreFeedbooksStore(StoreBase): name = 'Feedbooks' diff --git a/src/calibre/gui2/store/stores/empik_plugin.py b/src/calibre/gui2/store/stores/empik_plugin.py index 54f7bc25d4..4303298fde 100644 --- a/src/calibre/gui2/store/stores/empik_plugin.py +++ b/src/calibre/gui2/store/stores/empik_plugin.py @@ -1,14 +1,15 @@ # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) -store_version = 5 # Needed for dynamic plugin loading +store_version = 6 # Needed for dynamic plugin loading __license__ = 'GPL 3' -__copyright__ = '2011-2014, Tomasz Długosz ' +__copyright__ = '2011-2015, Tomasz Długosz ' __docformat__ = 'restructuredtext en' import re import urllib +from base64 import b64encode from contextlib import closing from lxml import html @@ -25,12 +26,20 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog class EmpikStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): + aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/78/58/' + url = 'http://www.empik.com/ebooki' + 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 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) + 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_()