[exhentai] retry failed api calls
This commit is contained in:
@@ -13,6 +13,7 @@ from .. import config, text, iso639_1, exception
|
|||||||
from ..cache import cache
|
from ..cache import cache
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
|
import requests
|
||||||
|
|
||||||
class ExhentaiGalleryExtractor(Extractor):
|
class ExhentaiGalleryExtractor(Extractor):
|
||||||
"""Extractor for image-galleries from exhentai.org"""
|
"""Extractor for image-galleries from exhentai.org"""
|
||||||
@@ -132,7 +133,14 @@ class ExhentaiGalleryExtractor(Extractor):
|
|||||||
if imgkey == nextkey:
|
if imgkey == nextkey:
|
||||||
return
|
return
|
||||||
self.wait()
|
self.wait()
|
||||||
page = self.session.post(self.api_url, json=request).json()
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
page = self.session.post(self.api_url, json=request).json()
|
||||||
|
break
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
self.wait((5, 10))
|
||||||
|
|
||||||
imgkey = nextkey
|
imgkey = nextkey
|
||||||
nextkey, pos = text.extract(page["i3"], "'", "'")
|
nextkey, pos = text.extract(page["i3"], "'", "'")
|
||||||
imgurl , pos = text.extract(page["i3"], '<img id="img" src="', '"', pos)
|
imgurl , pos = text.extract(page["i3"], '<img id="img" src="', '"', pos)
|
||||||
|
|||||||
Reference in New Issue
Block a user