[pinterest] support 'pin.it' board redirects (#7805)

This commit is contained in:
Mike Fährmann
2025-07-11 19:07:01 +02:00
parent 8e40ea2fe2
commit 2ccb9acf1a
2 changed files with 17 additions and 3 deletions

View File

@@ -396,9 +396,16 @@ class PinterestPinitExtractor(PinterestExtractor):
url = (f"https://api.pinterest.com/url_shortener"
f"/{self.groups[0]}/redirect/")
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")
yield Message.Queue, location, {"_extractor": PinterestPinExtractor}
class PinterestAPI():

View File

@@ -221,7 +221,14 @@ __tests__ = (
"#url" : "https://pin.it/Hvt8hgT",
"#category": ("", "pinterest", "pinit"),
"#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+",
},
{