[reddit] catch JSON decode errors (#765)

This commit is contained in:
Mike Fährmann
2020-06-11 18:32:52 +02:00
parent cf863f60b3
commit be04e44e2c

View File

@@ -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()