[pinterest] support 'pin.it' board redirects (#7805)
This commit is contained in:
@@ -396,9 +396,16 @@ class PinterestPinitExtractor(PinterestExtractor):
|
|||||||
url = (f"https://api.pinterest.com/url_shortener"
|
url = (f"https://api.pinterest.com/url_shortener"
|
||||||
f"/{self.groups[0]}/redirect/")
|
f"/{self.groups[0]}/redirect/")
|
||||||
location = self.request_location(url)
|
location = self.request_location(url)
|
||||||
if not location or not PinterestPinExtractor.pattern.match(location):
|
if not location:
|
||||||
|
raise exception.NotFoundError("pin")
|
||||||
|
elif PinterestPinExtractor.pattern.match(location):
|
||||||
|
yield Message.Queue, location, {
|
||||||
|
"_extractor": PinterestPinExtractor}
|
||||||
|
elif PinterestBoardExtractor.pattern.match(location):
|
||||||
|
yield Message.Queue, location, {
|
||||||
|
"_extractor": PinterestBoardExtractor}
|
||||||
|
else:
|
||||||
raise exception.NotFoundError("pin")
|
raise exception.NotFoundError("pin")
|
||||||
yield Message.Queue, location, {"_extractor": PinterestPinExtractor}
|
|
||||||
|
|
||||||
|
|
||||||
class PinterestAPI():
|
class PinterestAPI():
|
||||||
|
|||||||
@@ -221,7 +221,14 @@ __tests__ = (
|
|||||||
"#url" : "https://pin.it/Hvt8hgT",
|
"#url" : "https://pin.it/Hvt8hgT",
|
||||||
"#category": ("", "pinterest", "pinit"),
|
"#category": ("", "pinterest", "pinit"),
|
||||||
"#class" : pinterest.PinterestPinitExtractor,
|
"#class" : pinterest.PinterestPinitExtractor,
|
||||||
"#sha1_url": "8daad8558382c68f0868bdbd17d05205184632fa",
|
"#results" : "https://www.pinterest.com/pin/858146903966145191/sent/?sender=858147041405047427&invite_code=d7494ea7610c324ffc1ef6c20c4e29c4",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://pin.it/72hPRLLfr",
|
||||||
|
"#comment" : "board redirect (#7805)",
|
||||||
|
"#class" : pinterest.PinterestPinitExtractor,
|
||||||
|
"#pattern" : r"https://www.pinterest.ru/tarvenck/%D0%B0%D1%82%D0%BC%D0%BE%D1%81%D1%84%D0%B5%D1%80%D0%BD%D1%8B%D0%B5/\?invite_code=\w+&sender=\d+",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user