From 5a3667e7013da15e2608669eae996142acf93e02 Mon Sep 17 00:00:00 2001 From: John Schember Date: Fri, 11 Mar 2011 06:58:52 -0500 Subject: [PATCH] Add Kovid's pubid for B&N. --- src/calibre/gui2/store/bn_plugin.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/store/bn_plugin.py b/src/calibre/gui2/store/bn_plugin.py index 77b982af4a..d36d8e466e 100644 --- a/src/calibre/gui2/store/bn_plugin.py +++ b/src/calibre/gui2/store/bn_plugin.py @@ -6,6 +6,7 @@ __license__ = 'GPL 3' __copyright__ = '2011, John Schember ' __docformat__ = 'restructuredtext en' +import random import re import urllib2 from contextlib import closing @@ -25,13 +26,19 @@ class BNStore(BasicStoreConfig, StorePlugin): def open(self, parent=None, detail_item=None, external=False): settings = self.get_settings() - url = 'http://gan.doubleclick.net/gan_click?lid=41000000028437369&pubid=21000000000352219' + + pub_id = '21000000000352219' + # Use Kovid's affiliate id 30% of the time. + if random.randint(1, 10) in (1, 2, 3): + pub_id = '21000000000352583' + + url = 'http://gan.doubleclick.net/gan_click?lid=41000000028437369&pubid=' + pub_id if detail_item: mo = re.search(r'(?<=/)(?P\d+)(?=/|$)', detail_item) if mo: isbn = mo.group('isbn') - detail_item = 'http://gan.doubleclick.net/gan_click?lid=41000000012871747&pid=' + isbn + '&adurl=' + detail_item + '&pubid=21000000000352219' + detail_item = 'http://gan.doubleclick.net/gan_click?lid=41000000012871747&pid=' + isbn + '&adurl=' + detail_item + '&pubid=' + pub_id if external or settings.get(self.name + '_open_external', False): open_url(QUrl(url_slash_cleaner(detail_item if detail_item else url)))