From 2ccb9acf1a0a53d7a25732e65c9daef89595fc3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 11 Jul 2025 19:07:01 +0200 Subject: [PATCH] [pinterest] support 'pin.it' board redirects (#7805) --- gallery_dl/extractor/pinterest.py | 11 +++++++++-- test/results/pinterest.py | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/pinterest.py b/gallery_dl/extractor/pinterest.py index da93e80c..7ceb613c 100644 --- a/gallery_dl/extractor/pinterest.py +++ b/gallery_dl/extractor/pinterest.py @@ -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(): diff --git a/test/results/pinterest.py b/test/results/pinterest.py index 94b895cf..f55fa5e4 100644 --- a/test/results/pinterest.py +++ b/test/results/pinterest.py @@ -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+", }, {