[pinterest] catch JSON decode errors

This commit is contained in:
Mike Fährmann 2018-05-11 17:28:34 +02:00
parent 789608c107
commit e1e23165a0
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 8 additions and 2 deletions

View File

@ -72,7 +72,7 @@ class PinterestBoardExtractor(PinterestExtractor):
"url": "85911dfca313f3f7f48c2aa0bc684f539d1d80a6",
}),
("https://www.pinterest.com/g1952848/test/", {
"exception": exception.NotFoundError,
"exception": exception.GalleryDLException,
}),
]
@ -161,7 +161,11 @@ class PinterestAPI():
response = self.extractor.request(
url, params=params, headers=self.HEADERS, fatal=False)
data = response.json()
try:
data = response.json()
except ValueError:
data = {}
if 200 <= response.status_code < 400 and not response.history:
return data
@ -169,6 +173,7 @@ class PinterestAPI():
if response.status_code == 404 or response.history:
raise exception.NotFoundError(self.extractor.subcategory)
self.extractor.log.error("API request failed")
self.extractor.log.debug("%s", response.text)
raise exception.StopExtraction()
def _pagination(self, resource, options):

View File

@ -21,6 +21,7 @@ TRAVIS_SKIP = {
# temporary issues, etc.
BROKEN = {
"dokireader", # SSL cert expired
"pixiv", # API requests sometimes fail
}