From ec5870576d3a7243ccd1e3279e35bd964fa17e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 30 Jul 2020 18:24:38 +0200 Subject: [PATCH] [imgur] handle 403 overcapacity responses (closes #910) --- gallery_dl/extractor/imgur.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/imgur.py b/gallery_dl/extractor/imgur.py index a617975d..25328abe 100644 --- a/gallery_dl/extractor/imgur.py +++ b/gallery_dl/extractor/imgur.py @@ -332,9 +332,15 @@ class ImgurAPI(): 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