Skip to content

Commit

Permalink
[imgur] handle 403 overcapacity responses (closes #910)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 30, 2020
1 parent d6a271d commit ec58705
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gallery_dl/extractor/imgur.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,15 @@ def image(self, image_hash):
return self._call("image/" + image_hash)

def _call(self, endpoint):
return self.extractor.request(
"https://api.imgur.com/3/" + endpoint, headers=self.headers,
).json()["data"]
try:
return self.extractor.request(
"https://api.imgur.com/3/" + endpoint, headers=self.headers,
).json()["data"]
except exception.HttpError as exc:
if exc.status != 403 or b"capacity" not in exc.response.content:
raise
self.extractor.sleep(seconds=600)
return self._call(endpoint)

def _pagination(self, endpoint):
num = 0
Expand Down

0 comments on commit ec58705

Please sign in to comment.