mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Make amazon EU store plugins more robust against amazon reporting zero books found.
This commit is contained in:
parent
40dbdc75ae
commit
7169ffed0a
@ -7,7 +7,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import re, time
|
||||
from contextlib import closing
|
||||
from lxml import html
|
||||
|
||||
@ -29,6 +29,9 @@ class AmazonEUBase(StorePlugin):
|
||||
For comments on the implementation, please see amazon_plugin.py
|
||||
'''
|
||||
|
||||
MAX_SEARCH_ATTEMPTS = 5
|
||||
SLEEP_BETWEEN_ATTEMPTS = 3
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
|
||||
store_link = self.store_link % self.aff_id
|
||||
@ -42,6 +45,15 @@ class AmazonEUBase(StorePlugin):
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
loops = 0
|
||||
while counter == max_results and loops < self.MAX_SEARCH_ATTEMPTS:
|
||||
br = browser()
|
||||
if loops > 0:
|
||||
print ("Retry getbooks search", self.__class__.__name__, counter,
|
||||
max_results, loops)
|
||||
time.sleep(self.SLEEP_BETWEEN_ATTEMPTS)
|
||||
loops += 1
|
||||
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())#.decode('latin-1', 'replace'))
|
||||
|
||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import re, time
|
||||
from contextlib import closing
|
||||
from lxml import html
|
||||
|
||||
@ -28,6 +28,9 @@ class AmazonEUBase(StorePlugin):
|
||||
For comments on the implementation, please see amazon_plugin.py
|
||||
'''
|
||||
|
||||
MAX_SEARCH_ATTEMPTS = 5
|
||||
SLEEP_BETWEEN_ATTEMPTS = 3
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
|
||||
store_link = self.store_link % self.aff_id
|
||||
@ -41,6 +44,15 @@ class AmazonEUBase(StorePlugin):
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
loops = 0
|
||||
while counter == max_results and loops < self.MAX_SEARCH_ATTEMPTS:
|
||||
br = browser()
|
||||
if loops > 0:
|
||||
print ("Retry getbooks search", self.__class__.__name__, counter,
|
||||
max_results, loops)
|
||||
time.sleep(self.SLEEP_BETWEEN_ATTEMPTS)
|
||||
loops += 1
|
||||
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())#.decode('latin-1', 'replace'))
|
||||
|
||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import re, time
|
||||
from contextlib import closing
|
||||
from lxml import html
|
||||
|
||||
@ -29,6 +29,9 @@ class AmazonEUBase(StorePlugin):
|
||||
For comments on the implementation, please see amazon_plugin.py
|
||||
'''
|
||||
|
||||
MAX_SEARCH_ATTEMPTS = 5
|
||||
SLEEP_BETWEEN_ATTEMPTS = 3
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
|
||||
store_link = self.store_link % self.aff_id
|
||||
@ -42,6 +45,15 @@ class AmazonEUBase(StorePlugin):
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
loops = 0
|
||||
while counter == max_results and loops < self.MAX_SEARCH_ATTEMPTS:
|
||||
br = browser()
|
||||
if loops > 0:
|
||||
print ("Retry getbooks search", self.__class__.__name__, counter,
|
||||
max_results, loops)
|
||||
time.sleep(self.SLEEP_BETWEEN_ATTEMPTS)
|
||||
loops += 1
|
||||
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())#.decode('latin-1', 'replace'))
|
||||
|
||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import re, time
|
||||
from contextlib import closing
|
||||
from lxml import html
|
||||
|
||||
@ -28,6 +28,9 @@ class AmazonEUBase(StorePlugin):
|
||||
For comments on the implementation, please see amazon_plugin.py
|
||||
'''
|
||||
|
||||
MAX_SEARCH_ATTEMPTS = 5
|
||||
SLEEP_BETWEEN_ATTEMPTS = 3
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
|
||||
store_link = self.store_link % self.aff_id
|
||||
@ -41,6 +44,15 @@ class AmazonEUBase(StorePlugin):
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
loops = 0
|
||||
while counter == max_results and loops < self.MAX_SEARCH_ATTEMPTS:
|
||||
br = browser()
|
||||
if loops > 0:
|
||||
print ("Retry getbooks search", self.__class__.__name__, counter,
|
||||
max_results, loops)
|
||||
time.sleep(self.SLEEP_BETWEEN_ATTEMPTS)
|
||||
loops += 1
|
||||
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())#.decode('latin-1', 'replace'))
|
||||
|
||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import re, time
|
||||
from contextlib import closing
|
||||
from lxml import html
|
||||
|
||||
@ -28,6 +28,9 @@ class AmazonEUBase(StorePlugin):
|
||||
For comments on the implementation, please see amazon_plugin.py
|
||||
'''
|
||||
|
||||
MAX_SEARCH_ATTEMPTS = 5
|
||||
SLEEP_BETWEEN_ATTEMPTS = 3
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
|
||||
store_link = self.store_link % self.aff_id
|
||||
@ -41,6 +44,15 @@ class AmazonEUBase(StorePlugin):
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
loops = 0
|
||||
while counter == max_results and loops < self.MAX_SEARCH_ATTEMPTS:
|
||||
br = browser()
|
||||
if loops > 0:
|
||||
print ("Retry getbooks search", self.__class__.__name__, counter,
|
||||
max_results, loops)
|
||||
time.sleep(self.SLEEP_BETWEEN_ATTEMPTS)
|
||||
loops += 1
|
||||
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())#.decode('latin-1', 'replace'))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user