[pinterest] improve detection of invalid pin.it links
This commit is contained in:
@@ -153,7 +153,7 @@ class ImgurAlbumExtractor(ImgurExtractor):
|
|||||||
"is_album" : True,
|
"is_album" : True,
|
||||||
"layout" : "blog",
|
"layout" : "blog",
|
||||||
"link" : "https://imgur.com/a/TcBmP",
|
"link" : "https://imgur.com/a/TcBmP",
|
||||||
"nsfw" : True,
|
"nsfw" : bool,
|
||||||
"privacy" : "hidden",
|
"privacy" : "hidden",
|
||||||
"section" : None,
|
"section" : None,
|
||||||
"title" : "138",
|
"title" : "138",
|
||||||
|
|||||||
@@ -60,9 +60,8 @@ class PinterestPinExtractor(PinterestExtractor):
|
|||||||
test = (
|
test = (
|
||||||
("https://www.pinterest.com/pin/858146903966145189/", {
|
("https://www.pinterest.com/pin/858146903966145189/", {
|
||||||
"url": "afb3c26719e3a530bb0e871c480882a801a4e8a5",
|
"url": "afb3c26719e3a530bb0e871c480882a801a4e8a5",
|
||||||
# image version depends on CDN server used
|
"content": ("4c435a66f6bb82bb681db2ecc888f76cf6c5f9ca",
|
||||||
# "content": "d3e24bc9f7af585e8c23b9136956bd45a4d9b947",
|
"d3e24bc9f7af585e8c23b9136956bd45a4d9b947"),
|
||||||
# "content": "4c435a66f6bb82bb681db2ecc888f76cf6c5f9ca",
|
|
||||||
}),
|
}),
|
||||||
("https://www.pinterest.com/pin/858146903966145188/", {
|
("https://www.pinterest.com/pin/858146903966145188/", {
|
||||||
"exception": exception.NotFoundError,
|
"exception": exception.NotFoundError,
|
||||||
@@ -171,9 +170,7 @@ class PinterestPinitExtractor(PinterestExtractor):
|
|||||||
self.shortened_id)
|
self.shortened_id)
|
||||||
response = self.request(url, method="HEAD", allow_redirects=False)
|
response = self.request(url, method="HEAD", allow_redirects=False)
|
||||||
location = response.headers.get("Location")
|
location = response.headers.get("Location")
|
||||||
if not location or location in ("https://api.pinterest.com/None",
|
if not location or not PinterestPinExtractor.pattern.match(location):
|
||||||
"https://pin.it/None",
|
|
||||||
"https://www.pinterest.com"):
|
|
||||||
raise exception.NotFoundError("pin")
|
raise exception.NotFoundError("pin")
|
||||||
yield Message.Queue, location, {"_extractor": PinterestPinExtractor}
|
yield Message.Queue, location, {"_extractor": PinterestPinExtractor}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class XhamsterUserExtractor(XhamsterExtractor):
|
|||||||
subcategory = "user"
|
subcategory = "user"
|
||||||
pattern = BASE_PATTERN + r"/users/([^/?&#]+)(?:/photos)?/?(?:$|[?#])"
|
pattern = BASE_PATTERN + r"/users/([^/?&#]+)(?:/photos)?/?(?:$|[?#])"
|
||||||
test = (
|
test = (
|
||||||
("https://xhamster.com/users/nickname68/photos", {
|
("https://xhamster.com/users/goldenpalomino/photos", {
|
||||||
"pattern": XhamsterGalleryExtractor.pattern,
|
"pattern": XhamsterGalleryExtractor.pattern,
|
||||||
"count": 50,
|
"count": 50,
|
||||||
"range": "1-50",
|
"range": "1-50",
|
||||||
|
|||||||
Reference in New Issue
Block a user