File Update-amazon-store-plugin.patch of Package calibre

From b201d1e4abff2695f3f40d91d2faef4565c3b318 Mon Sep 17 00:00:00 2001
From: Kovid Goyal <kovid@kovidgoyal.net>
Date: Tue, 4 Oct 2016 08:06:41 +0530
Subject: [PATCH] Get Books: Update the amazon store plugins for website
 changes

---
 src/calibre/gui2/store/stores/amazon_au_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_ca_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_de_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_es_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_fr_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_in_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_it_plugin.py | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_plugin.py    | 9 ++++++---
 src/calibre/gui2/store/stores/amazon_uk_plugin.py | 9 ++++++---
 9 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/src/calibre/gui2/store/stores/amazon_au_plugin.py b/src/calibre/gui2/store/stores/amazon_au_plugin.py
index 4acf286..610358f 100644
--- a/src/calibre/gui2/store/stores/amazon_au_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_au_plugin.py
@@ -4,7 +4,7 @@
 
 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
 
 from contextlib import closing
 import urllib
@@ -25,6 +25,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -39,7 +42,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -120,7 +123,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_ca_plugin.py b/src/calibre/gui2/store/stores/amazon_ca_plugin.py
index 543985a..923379f 100644
--- a/src/calibre/gui2/store/stores/amazon_ca_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_ca_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 3  # Needed for dynamic plugin loading
+store_version = 4  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -25,6 +25,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -39,7 +42,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -120,7 +123,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_de_plugin.py b/src/calibre/gui2/store/stores/amazon_de_plugin.py
index 4bd191f..b357d5f 100644
--- a/src/calibre/gui2/store/stores/amazon_de_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_de_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 11  # Needed for dynamic plugin loading
+store_version = 12  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -27,6 +27,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -41,7 +44,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -122,7 +125,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_es_plugin.py b/src/calibre/gui2/store/stores/amazon_es_plugin.py
index 9b07163..ebfb64e 100644
--- a/src/calibre/gui2/store/stores/amazon_es_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_es_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 11  # Needed for dynamic plugin loading
+store_version = 12  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -27,6 +27,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -41,7 +44,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -122,7 +125,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_fr_plugin.py b/src/calibre/gui2/store/stores/amazon_fr_plugin.py
index 9684837..28f2a13 100644
--- a/src/calibre/gui2/store/stores/amazon_fr_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_fr_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 11  # Needed for dynamic plugin loading
+store_version = 12  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -27,6 +27,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -41,7 +44,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -122,7 +125,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_in_plugin.py b/src/calibre/gui2/store/stores/amazon_in_plugin.py
index 1f6afa8..3a5958d 100644
--- a/src/calibre/gui2/store/stores/amazon_in_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_in_plugin.py
@@ -4,7 +4,7 @@
 
 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
 
 from contextlib import closing
 import urllib
@@ -25,6 +25,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -39,7 +42,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -122,7 +125,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_it_plugin.py b/src/calibre/gui2/store/stores/amazon_it_plugin.py
index 3a2a364..a68747b 100644
--- a/src/calibre/gui2/store/stores/amazon_it_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_it_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 11  # Needed for dynamic plugin loading
+store_version = 12  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -27,6 +27,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -41,7 +44,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -122,7 +125,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_plugin.py b/src/calibre/gui2/store/stores/amazon_plugin.py
index afb06ec..398dbce 100644
--- a/src/calibre/gui2/store/stores/amazon_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 11  # Needed for dynamic plugin loading
+store_version = 12  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -25,6 +25,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -39,7 +42,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -157,7 +160,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
diff --git a/src/calibre/gui2/store/stores/amazon_uk_plugin.py b/src/calibre/gui2/store/stores/amazon_uk_plugin.py
index 1f3e248..2f4a0e0 100644
--- a/src/calibre/gui2/store/stores/amazon_uk_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_uk_plugin.py
@@ -4,7 +4,7 @@
 
 from __future__ import (unicode_literals, division, absolute_import,
                         print_function)
-store_version = 11  # Needed for dynamic plugin loading
+store_version = 12  # Needed for dynamic plugin loading
 
 from contextlib import closing
 import urllib
@@ -25,6 +25,9 @@
 DRM_SEARCH_TEXT = 'Simultaneous Device Usage'
 DRM_FREE_TEXT = 'Unlimited'
 
+def get_user_agent():
+    return 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'
+
 def search_amazon(query, max_results=10, timeout=60,
                   write_html_to=None,
                   base_url=SEARCH_BASE_URL,
@@ -39,7 +42,7 @@ def asbytes(x):
         return x
     uquery = {asbytes(k):asbytes(v) for k, v in uquery.iteritems()}
     url = base_url + '?' + urllib.urlencode(uquery).decode('ascii')
-    br = browser()
+    br = browser(user_agent=get_user_agent())
 
     counter = max_results
     with closing(br.open(url, timeout=timeout)) as f:
@@ -120,7 +123,7 @@ def search(self, query, max_results=10, timeout=60):
     def get_details(self, search_result, timeout):
         url = DETAILS_URL
 
-        br = browser()
+        br = browser(user_agent=get_user_agent())
         with closing(br.open(url + search_result.detail_item, timeout=timeout)) as nf:
             idata = html.fromstring(nf.read())
             if idata.xpath('boolean(//div[@class="content"]//li/b[contains(text(), "' +
openSUSE Build Service is sponsored by