From 10f603fb527bf628711abe9c59245fd4ea6ab3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82ugosz?= Date: Thu, 11 Apr 2013 00:56:34 +0200 Subject: [PATCH] Woblink as an affiliate --- src/calibre/customize/builtins.py | 1 + src/calibre/gui2/store/stores/koobe_plugin.py | 2 +- src/calibre/gui2/store/stores/woblink_plugin.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index d54527bea5..ba5e316c6f 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1660,6 +1660,7 @@ class StoreWoblinkStore(StoreBase): headquarters = 'PL' formats = ['EPUB', 'MOBI', 'PDF', 'WOBLINK'] + affiliate = True class XinXiiStore(StoreBase): name = 'XinXii' diff --git a/src/calibre/gui2/store/stores/koobe_plugin.py b/src/calibre/gui2/store/stores/koobe_plugin.py index 12f1905bfe..343e6ffec9 100644 --- a/src/calibre/gui2/store/stores/koobe_plugin.py +++ b/src/calibre/gui2/store/stores/koobe_plugin.py @@ -38,7 +38,7 @@ class KoobeStore(BasicStoreConfig, StorePlugin): if external or self.config.get('open_external', False): 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_() diff --git a/src/calibre/gui2/store/stores/woblink_plugin.py b/src/calibre/gui2/store/stores/woblink_plugin.py index 63ec259dbf..596bb76199 100644 --- a/src/calibre/gui2/store/stores/woblink_plugin.py +++ b/src/calibre/gui2/store/stores/woblink_plugin.py @@ -1,14 +1,15 @@ # -*- coding: utf-8 -*- from __future__ import (unicode_literals, division, absolute_import, print_function) -store_version = 1 # Needed for dynamic plugin loading +store_version = 2 # Needed for dynamic plugin loading __license__ = 'GPL 3' -__copyright__ = '2011-2012, Tomasz Długosz ' +__copyright__ = '2011-2013, Tomasz Długosz ' __docformat__ = 'restructuredtext en' import re import urllib +from base64 import b64encode from contextlib import closing from lxml import html @@ -25,17 +26,19 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog class WoblinkStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): - + aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/16/58/' url = 'http://woblink.com/publication' + + aff_url = aff_root + str(b64encode(url)) detail_url = None if detail_item: - detail_url = 'http://woblink.com' + detail_item + detail_url = aff_root + str(b64encode('http://woblink.com' + detail_item)) 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_()