Merge lp:~user-none/calibre/dev into lp:calibre

Proposed by John Schember
Status: Merged
Merged at revision: 13603
Proposed branch: lp:~user-none/calibre/dev
Merge into: lp:calibre
Diff against target: 126 lines (+25/-31)
2 files modified
src/calibre/gui2/store/stores/eharlequin_plugin.py (+4/-16)
src/calibre/gui2/store/stores/kobo_plugin.py (+21/-15)
To merge this branch: bzr merge lp:~user-none/calibre/dev
Reviewer Review Type Date Requested Status
Kovid Goyal Pending
Review via email: mp+132641@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/calibre/gui2/store/stores/eharlequin_plugin.py'
2--- src/calibre/gui2/store/stores/eharlequin_plugin.py 2011-06-26 15:15:19 +0000
3+++ src/calibre/gui2/store/stores/eharlequin_plugin.py 2012-11-02 01:59:22 +0000
4@@ -6,7 +6,6 @@
5 __copyright__ = '2011, John Schember <john@nachtimwald.com>'
6 __docformat__ = 'restructuredtext en'
7
8-import random
9 import re
10 import urllib2
11 from contextlib import closing
12@@ -25,23 +24,12 @@
13 class EHarlequinStore(BasicStoreConfig, StorePlugin):
14
15 def open(self, parent=None, detail_item=None, external=False):
16- m_url = 'http://www.dpbolvw.net/'
17- h_click = 'click-4879827-534091'
18- d_click = 'click-4879827-10375439'
19- # Use Kovid's affiliate id 30% of the time.
20- if random.randint(1, 10) in (1, 2, 3):
21- h_click = 'click-4913808-534091'
22- d_click = 'click-4913808-10375439'
23-
24- url = m_url + h_click
25- detail_url = None
26- if detail_item:
27- detail_url = m_url + d_click + detail_item
28+ url = 'http://www.harlequin.com/'
29
30 if external or self.config.get('open_external', False):
31- open_url(QUrl(url_slash_cleaner(detail_url if detail_url else url)))
32+ open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))
33 else:
34- d = WebStoreDialog(self.gui, url, parent, detail_url)
35+ d = WebStoreDialog(self.gui, url, parent, detail_item)
36 d.setWindowTitle(self.name)
37 d.set_tags(self.config.get('tags', ''))
38 d.exec_()
39@@ -74,7 +62,7 @@
40 s.title = title.strip()
41 s.author = author.strip()
42 s.price = price.strip()
43- s.detail_item = '?url=http://ebooks.eharlequin.com/' + id.strip()
44+ s.detail_item = 'http://ebooks.eharlequin.com/' + id.strip()
45 s.formats = 'EPUB'
46
47 yield s
48
49=== modified file 'src/calibre/gui2/store/stores/kobo_plugin.py'
50--- src/calibre/gui2/store/stores/kobo_plugin.py 2012-05-19 16:01:02 +0000
51+++ src/calibre/gui2/store/stores/kobo_plugin.py 2012-11-02 01:59:22 +0000
52@@ -7,6 +7,7 @@
53 __docformat__ = 'restructuredtext en'
54
55 import random
56+import urllib
57 import urllib2
58 from contextlib import closing
59
60@@ -24,23 +25,24 @@
61 class KoboStore(BasicStoreConfig, StorePlugin):
62
63 def open(self, parent=None, detail_item=None, external=False):
64- m_url = 'http://www.dpbolvw.net/'
65- h_click = 'click-4879827-10762497'
66- d_click = 'click-4879827-10772898'
67+ pub_id = 'sHa5EXvYOwA'
68 # Use Kovid's affiliate id 30% of the time.
69 if random.randint(1, 10) in (1, 2, 3):
70- h_click = 'click-4913808-10762497'
71- d_click = 'click-4913808-10772898'
72-
73- url = m_url + h_click
74- detail_url = None
75+ pub_id = '0dsO3kDu/AU'
76+
77+ murl = 'http://click.linksynergy.com/fs-bin/click?id=%s&offerid=268429.4&type=3&subid=0' % pub_id
78+
79 if detail_item:
80- detail_url = m_url + d_click + detail_item
81+ purl = 'http://click.linksynergy.com/link?id=%s&offerid=268429&type=2&murl=%s' % (pub_id, urllib.quote_plus(detail_item))
82+ url = purl
83+ else:
84+ purl = None
85+ url = murl
86
87 if external or self.config.get('open_external', False):
88- open_url(QUrl(url_slash_cleaner(detail_url if detail_url else url)))
89+ open_url(QUrl(url_slash_cleaner(url)))
90 else:
91- d = WebStoreDialog(self.gui, url, parent, detail_url)
92+ d = WebStoreDialog(self.gui, murl, parent, purl)
93 d.setWindowTitle(self.name)
94 d.set_tags(self.config.get('tags', ''))
95 d.exec_()
96@@ -60,15 +62,19 @@
97 id = ''.join(data.xpath('.//div[@class="SearchImageContainer"]/a[1]/@href'))
98 if not id:
99 continue
100+ try:
101+ id = id.split('?', 1)[0]
102+ except:
103+ continue
104
105- price = ''.join(data.xpath('.//span[@class="OurPrice"]/strong/text()'))
106+ price = ''.join(data.xpath('.//span[@class="KV2OurPrice"]/strong/text()'))
107 if not price:
108 price = '$0.00'
109
110 cover_url = ''.join(data.xpath('.//div[@class="SearchImageContainer"]//img[1]/@src'))
111
112- title = ''.join(data.xpath('.//div[@class="SCItemHeader"]/h1/a[1]/text()'))
113- author = ', '.join(data.xpath('.//div[@class="SCItemSummary"]//span//a/text()'))
114+ title = ''.join(data.xpath('.//div[@class="SCItemHeader"]//a[1]/text()'))
115+ author = ', '.join(data.xpath('.//div[@class="SCItemSummary"]//span[contains(@class, "Author")]//a/text()'))
116 drm = data.xpath('boolean(.//span[@class="SCAvailibilityFormatsText" and not(contains(text(), "DRM-Free"))])')
117
118 counter -= 1
119@@ -78,7 +84,7 @@
120 s.title = title.strip()
121 s.author = author.strip()
122 s.price = price.strip()
123- s.detail_item = '?url=http://www.kobobooks.com/' + id.strip()
124+ s.detail_item = 'http://www.kobobooks.com/' + id.strip()
125 s.drm = SearchResult.DRM_LOCKED if drm else SearchResult.DRM_UNLOCKED
126 s.formats = 'EPUB'
127

Subscribers

People subscribed via source and target branches

to status/vote changes: