From be04e44e2c613e0e53d34807936333f43b701702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 11 Jun 2020 18:32:52 +0200 Subject: [PATCH] [reddit] catch JSON decode errors (#765) --- gallery_dl/extractor/reddit.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/reddit.py b/gallery_dl/extractor/reddit.py index 2e3864a3..6331b774 100644 --- a/gallery_dl/extractor/reddit.py +++ b/gallery_dl/extractor/reddit.py @@ -324,7 +324,11 @@ class RedditAPI(): self.extractor.wait(seconds=response.headers["x-ratelimit-reset"]) return self._call(endpoint, params) - data = response.json() + try: + data = response.json() + except ValueError: + raise exception.StopExtraction(text.remove_html(response.text)) + if "error" in data: if data["error"] == 403: raise exception.AuthorizationError()