Skip to content

Commit

Permalink
[nsfwalbum] retry backend requests (fixes #1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 29, 2021
1 parent 6c11105 commit 4e95cef
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gallery_dl/extractor/nsfwalbum.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,24 @@ def metadata(self, page):
def images(self, page):
iframe = self.root + "/iframe_image.php?id="
backend = self.root + "/backend.php"
retries = self._retries

for image_id in text.extract_iter(page, 'data-img-id="', '"'):
spirit = self._annihilate(text.extract(self.request(
iframe + image_id).text, 'giraffe.annihilate("', '"')[0])
params = {"spirit": spirit, "photo": image_id}
data = self.request(backend, params=params).json()

tries = 0
while tries <= retries:
try:
data = self.request(backend, params=params).json()
break
except Exception:
tries += 1
else:
self.log.warning("Unable to fetch image %s", image_id)
continue

yield data[0], {
"id" : text.parse_int(image_id),
"width" : text.parse_int(data[1]),
Expand Down

0 comments on commit 4e95cef

Please sign in to comment.