[pinterest] cast IDs to int
... and update test results. Image URLs changed from https://s-media-cache-ak0.pinimg.com/... to https://i.pinimg.com/...
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"""Extract images from https://www.pinterest.com"""
|
"""Extract images from https://www.pinterest.com"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, exception
|
from .. import text, util, exception
|
||||||
|
|
||||||
|
|
||||||
class PinterestExtractor(Extractor):
|
class PinterestExtractor(Extractor):
|
||||||
@@ -27,10 +27,10 @@ class PinterestExtractor(Extractor):
|
|||||||
img = pin["image"]["original"]
|
img = pin["image"]["original"]
|
||||||
url = img["url"]
|
url = img["url"]
|
||||||
data = {
|
data = {
|
||||||
"pin_id": pin["id"],
|
"pin_id": util.safe_int(pin["id"]),
|
||||||
"note": pin["note"],
|
"note": pin["note"],
|
||||||
"width": img["width"],
|
"width": util.safe_int(img["width"]),
|
||||||
"height": img["height"],
|
"height": util.safe_int(img["height"]),
|
||||||
}
|
}
|
||||||
return url, text.nameext_from_url(url, data)
|
return url, text.nameext_from_url(url, data)
|
||||||
|
|
||||||
@@ -41,8 +41,8 @@ class PinterestPinExtractor(PinterestExtractor):
|
|||||||
pattern = [r"(?:https?://)?(?:[^./]+\.)?pinterest\.[^/]+/pin/([^/?#&]+)"]
|
pattern = [r"(?:https?://)?(?:[^./]+\.)?pinterest\.[^/]+/pin/([^/?#&]+)"]
|
||||||
test = [
|
test = [
|
||||||
("https://www.pinterest.com/pin/858146903966145189/", {
|
("https://www.pinterest.com/pin/858146903966145189/", {
|
||||||
"url": "7abf2be76bf03d452feacf6e000b040fc2706b80",
|
"url": "afb3c26719e3a530bb0e871c480882a801a4e8a5",
|
||||||
"keyword": "5aac8028244b865824c61667f6cadd51e8765853",
|
"keyword": "f651cb271247f306d1d30385d49c7b82da44c2b1",
|
||||||
"content": "d3e24bc9f7af585e8c23b9136956bd45a4d9b947",
|
"content": "d3e24bc9f7af585e8c23b9136956bd45a4d9b947",
|
||||||
}),
|
}),
|
||||||
("https://www.pinterest.com/pin/858146903966145188/", {
|
("https://www.pinterest.com/pin/858146903966145188/", {
|
||||||
@@ -70,8 +70,8 @@ class PinterestBoardExtractor(PinterestExtractor):
|
|||||||
r"(?!pin/)([^/?#&]+)/([^/?#&]+)"]
|
r"(?!pin/)([^/?#&]+)/([^/?#&]+)"]
|
||||||
test = [
|
test = [
|
||||||
("https://www.pinterest.com/g1952849/test-/", {
|
("https://www.pinterest.com/g1952849/test-/", {
|
||||||
"url": "705ee521630a5d613b0449d694a5345e684572a9",
|
"url": "85911dfca313f3f7f48c2aa0bc684f539d1d80a6",
|
||||||
"keyword": "1650dd31c4dedd940cef399135e485400625ec0b",
|
"keyword": "c54cf5aa830994f2ed4871efa7154a5fdaa1c2ce",
|
||||||
}),
|
}),
|
||||||
("https://www.pinterest.com/g1952848/test/", {
|
("https://www.pinterest.com/g1952848/test/", {
|
||||||
"exception": exception.NotFoundError,
|
"exception": exception.NotFoundError,
|
||||||
@@ -99,7 +99,7 @@ class PinterestBoardExtractor(PinterestExtractor):
|
|||||||
"""Get metadata from a board-object"""
|
"""Get metadata from a board-object"""
|
||||||
data = {
|
data = {
|
||||||
"user": self.user,
|
"user": self.user,
|
||||||
"board_id": board["id"],
|
"board_id": util.safe_int(board["id"]),
|
||||||
"board": board["name"],
|
"board": board["name"],
|
||||||
"count": board["counts"]["pins"],
|
"count": board["counts"]["pins"],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user