From d7823b9f819acdbc38c83de413700a5c45f5cdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 5 Feb 2024 15:54:06 +0100 Subject: [PATCH] [pinterest] fix section URLs for boards with /?# in name (#5104) --- gallery_dl/extractor/pinterest.py | 5 ++--- test/results/pinterest.py | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/pinterest.py b/gallery_dl/extractor/pinterest.py index c46a5879..8c04ed59 100644 --- a/gallery_dl/extractor/pinterest.py +++ b/gallery_dl/extractor/pinterest.py @@ -149,8 +149,7 @@ class PinterestBoardExtractor(PinterestExtractor): pins = self.api.board_pins(board["id"]) if board["section_count"] and self.config("sections", True): - base = "{}/{}/{}/id:".format( - self.root, board["owner"]["username"], board["name"]) + base = "{}{}id:".format(self.root, board["url"]) data = {"_extractor": PinterestSectionExtractor} sections = [(base + section["id"], data) for section in self.api.board_sections(board["id"])] @@ -220,7 +219,7 @@ class PinterestSectionExtractor(PinterestExtractor): "{board[name]}", "{section[title]}") archive_fmt = "{board[id]}_{id}" pattern = BASE_PATTERN + r"/(?!pin/)([^/?#]+)/([^/?#]+)/([^/?#]+)" - example = "https://www.pinterest.com/USER/BOARD/SEcTION" + example = "https://www.pinterest.com/USER/BOARD/SECTION" def __init__(self, match): PinterestExtractor.__init__(self, match) diff --git a/test/results/pinterest.py b/test/results/pinterest.py index e92e50ac..73bebfa4 100644 --- a/test/results/pinterest.py +++ b/test/results/pinterest.py @@ -52,6 +52,15 @@ __tests__ = ( "#count" : 4, }, +{ + "#url" : "https://www.pinterest.jp/gdldev/bname/", + "#comment" : "board & section with /?# in name (#5104)", + "#category": ("", "pinterest", "board"), + "#class" : pinterest.PinterestBoardExtractor, + "#options" : {"sections": True}, + "#urls" : "https://www.pinterest.jp/gdldev/bname/id:5345901183739414095", +}, + { "#url" : "https://www.pinterest.de/g1952849/secret/", "#comment" : "secret board (#1055)",