[pinterest] unquote board and user names, better errors
This commit is contained in:
@@ -76,7 +76,8 @@ class PinterestBoardExtractor(PinterestExtractor):
|
|||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
PinterestExtractor.__init__(self)
|
PinterestExtractor.__init__(self)
|
||||||
self.user, self.board = match.groups()
|
self.user = text.unquote(match.group(1))
|
||||||
|
self.board = text.unquote(match.group(2))
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
board = self.api.board(self.user, self.board)
|
board = self.api.board(self.user, self.board)
|
||||||
@@ -134,8 +135,7 @@ class PinterestAPI():
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, extractor):
|
def __init__(self, extractor):
|
||||||
self.log = extractor.log
|
self.extractor = extractor
|
||||||
self.session = extractor.session
|
|
||||||
|
|
||||||
def pin(self, pin_id):
|
def pin(self, pin_id):
|
||||||
"""Query information about a pin"""
|
"""Query information about a pin"""
|
||||||
@@ -157,20 +157,16 @@ class PinterestAPI():
|
|||||||
url = "{}/resource/{}Resource/get/".format(self.BASE_URL, resource)
|
url = "{}/resource/{}Resource/get/".format(self.BASE_URL, resource)
|
||||||
params = {"data": json.dumps({"options": options}), "source_url": ""}
|
params = {"data": json.dumps({"options": options}), "source_url": ""}
|
||||||
|
|
||||||
response = self.session.get(url, params=params, headers=self.HEADERS)
|
response = self.extractor.request(
|
||||||
|
url, params=params, headers=self.HEADERS, fatal=False)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
if 200 <= response.status_code < 400 and "resource_response" in data:
|
if 200 <= response.status_code < 400 and not response.history:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
try:
|
if response.status_code == 404 or response.history:
|
||||||
msg = data["resource_response"]["error"]["message"]
|
raise exception.NotFoundError(self.extractor.subcategory)
|
||||||
except KeyError:
|
self.extractor.log.error("API request failed")
|
||||||
msg = ""
|
|
||||||
if response.status_code == 404:
|
|
||||||
msg = msg.partition(" ")[0].lower()
|
|
||||||
raise exception.NotFoundError(msg)
|
|
||||||
self.log.error("API request failed: %s", msg)
|
|
||||||
raise exception.StopExtraction()
|
raise exception.StopExtraction()
|
||||||
|
|
||||||
def _pagination(self, resource, options):
|
def _pagination(self, resource, options):
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from gallery_dl import extractor, job, config, exception
|
|||||||
# these don't work on travis-ci
|
# these don't work on travis-ci
|
||||||
TRAVIS_SKIP = {
|
TRAVIS_SKIP = {
|
||||||
"exhentai", "kissmanga", "mangafox", "dynastyscans", "nijie",
|
"exhentai", "kissmanga", "mangafox", "dynastyscans", "nijie",
|
||||||
"archivedmoe", "archiveofsins", "thebarchive",
|
"archivedmoe", "archiveofsins", "thebarchive", "sankaku", "idolcomplex",
|
||||||
}
|
}
|
||||||
|
|
||||||
# temporary issues, etc.
|
# temporary issues, etc.
|
||||||
|
|||||||
Reference in New Issue
Block a user