diff --git a/src/calibre/gui2/store/stores/eharlequin_plugin.py b/src/calibre/gui2/store/stores/eharlequin_plugin.py index daa67e801c..ec85ccf1d3 100644 --- a/src/calibre/gui2/store/stores/eharlequin_plugin.py +++ b/src/calibre/gui2/store/stores/eharlequin_plugin.py @@ -6,7 +6,6 @@ __license__ = 'GPL 3' __copyright__ = '2011, John Schember ' __docformat__ = 'restructuredtext en' -import random import re import urllib2 from contextlib import closing @@ -25,23 +24,12 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog class EHarlequinStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): - m_url = 'http://www.dpbolvw.net/' - h_click = 'click-4879827-534091' - d_click = 'click-4879827-10375439' - # Use Kovid's affiliate id 30% of the time. - if random.randint(1, 10) in (1, 2, 3): - h_click = 'click-4913808-534091' - d_click = 'click-4913808-10375439' - - url = m_url + h_click - detail_url = None - if detail_item: - detail_url = m_url + d_click + detail_item + url = 'http://www.harlequin.com/' 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_item if detail_item else url))) else: - d = WebStoreDialog(self.gui, url, parent, detail_url) + d = WebStoreDialog(self.gui, url, parent, detail_item) d.setWindowTitle(self.name) d.set_tags(self.config.get('tags', '')) d.exec_() @@ -74,7 +62,7 @@ class EHarlequinStore(BasicStoreConfig, StorePlugin): s.title = title.strip() s.author = author.strip() s.price = price.strip() - s.detail_item = '?url=http://ebooks.eharlequin.com/' + id.strip() + s.detail_item = 'http://ebooks.eharlequin.com/' + id.strip() s.formats = 'EPUB' yield s diff --git a/src/calibre/gui2/store/stores/kobo_plugin.py b/src/calibre/gui2/store/stores/kobo_plugin.py index 0b2fc1c9a1..5a8b5618d5 100644 --- a/src/calibre/gui2/store/stores/kobo_plugin.py +++ b/src/calibre/gui2/store/stores/kobo_plugin.py @@ -7,6 +7,7 @@ __copyright__ = '2011, John Schember ' __docformat__ = 'restructuredtext en' import random +import urllib import urllib2 from contextlib import closing @@ -24,23 +25,24 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog class KoboStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): - m_url = 'http://www.dpbolvw.net/' - h_click = 'click-4879827-10762497' - d_click = 'click-4879827-10772898' + pub_id = 'sHa5EXvYOwA' # Use Kovid's affiliate id 30% of the time. if random.randint(1, 10) in (1, 2, 3): - h_click = 'click-4913808-10762497' - d_click = 'click-4913808-10772898' + pub_id = '0dsO3kDu/AU' + + murl = 'http://click.linksynergy.com/fs-bin/click?id=%s&offerid=268429.4&type=3&subid=0' % pub_id - url = m_url + h_click - detail_url = None if detail_item: - detail_url = m_url + d_click + detail_item + purl = 'http://click.linksynergy.com/link?id=%s&offerid=268429&type=2&murl=%s' % (pub_id, urllib.quote_plus(detail_item)) + url = purl + else: + purl = None + url = murl 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(url))) else: - d = WebStoreDialog(self.gui, url, parent, detail_url) + d = WebStoreDialog(self.gui, murl, parent, purl) d.setWindowTitle(self.name) d.set_tags(self.config.get('tags', '')) d.exec_() @@ -60,15 +62,19 @@ class KoboStore(BasicStoreConfig, StorePlugin): id = ''.join(data.xpath('.//div[@class="SearchImageContainer"]/a[1]/@href')) if not id: continue + try: + id = id.split('?', 1)[0] + except: + continue - price = ''.join(data.xpath('.//span[@class="OurPrice"]/strong/text()')) + price = ''.join(data.xpath('.//span[@class="KV2OurPrice"]/strong/text()')) if not price: price = '$0.00' cover_url = ''.join(data.xpath('.//div[@class="SearchImageContainer"]//img[1]/@src')) - title = ''.join(data.xpath('.//div[@class="SCItemHeader"]/h1/a[1]/text()')) - author = ', '.join(data.xpath('.//div[@class="SCItemSummary"]//span//a/text()')) + title = ''.join(data.xpath('.//div[@class="SCItemHeader"]//a[1]/text()')) + author = ', '.join(data.xpath('.//div[@class="SCItemSummary"]//span[contains(@class, "Author")]//a/text()')) drm = data.xpath('boolean(.//span[@class="SCAvailibilityFormatsText" and not(contains(text(), "DRM-Free"))])') counter -= 1 @@ -78,7 +84,7 @@ class KoboStore(BasicStoreConfig, StorePlugin): s.title = title.strip() s.author = author.strip() s.price = price.strip() - s.detail_item = '?url=http://www.kobobooks.com/' + id.strip() + s.detail_item = 'http://www.kobobooks.com/' + id.strip() s.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED s.formats = 'EPUB'