summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/pinterest.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/pinterest.py')
-rw-r--r--gallery_dl/extractor/pinterest.py104
1 files changed, 52 insertions, 52 deletions
diff --git a/gallery_dl/extractor/pinterest.py b/gallery_dl/extractor/pinterest.py
index 9c335ad..ff771fb 100644
--- a/gallery_dl/extractor/pinterest.py
+++ b/gallery_dl/extractor/pinterest.py
@@ -204,58 +204,6 @@ class PinterestExtractor(Extractor):
return media
-class PinterestPinExtractor(PinterestExtractor):
- """Extractor for images from a single pin from pinterest.com"""
- subcategory = "pin"
- pattern = BASE_PATTERN + r"/pin/([^/?#]+)(?!.*#related$)"
- example = "https://www.pinterest.com/pin/12345/"
-
- def __init__(self, match):
- PinterestExtractor.__init__(self, match)
- self.pin_id = match[1]
- self.pin = None
-
- def metadata(self):
- self.pin = self.api.pin(self.pin_id)
- return self.pin
-
- def pins(self):
- return (self.pin,)
-
-
-class PinterestBoardExtractor(PinterestExtractor):
- """Extractor for images from a board from pinterest.com"""
- subcategory = "board"
- directory_fmt = ("{category}", "{board[owner][username]}", "{board[name]}")
- archive_fmt = "{board[id]}_{id}"
- pattern = (BASE_PATTERN + r"/(?!pin/)([^/?#]+)"
- r"/(?!_saved|_created|pins/)([^/?#]+)/?(?:$|\?|#)")
- example = "https://www.pinterest.com/USER/BOARD/"
-
- def __init__(self, match):
- PinterestExtractor.__init__(self, match)
- self.user = text.unquote(match[1])
- self.board_name = text.unquote(match[2])
- self.board = None
-
- def metadata(self):
- self.board = self.api.board(self.user, self.board_name)
- return {"board": self.board}
-
- def pins(self):
- board = self.board
- pins = self.api.board_pins(board["id"])
-
- if board["section_count"] and self.config("sections", True):
- base = f"{self.root}{board['url']}id:"
- data = {"_extractor": PinterestSectionExtractor}
- sections = [(base + section["id"], data)
- for section in self.api.board_sections(board["id"])]
- pins = itertools.chain(pins, sections)
-
- return pins
-
-
class PinterestUserExtractor(PinterestExtractor):
"""Extractor for a user's boards"""
subcategory = "user"
@@ -357,6 +305,58 @@ class PinterestSearchExtractor(PinterestExtractor):
return self.api.search(self.search)
+class PinterestPinExtractor(PinterestExtractor):
+ """Extractor for images from a single pin from pinterest.com"""
+ subcategory = "pin"
+ pattern = BASE_PATTERN + r"/pin/([^/?#]+)(?!.*#related$)"
+ example = "https://www.pinterest.com/pin/12345/"
+
+ def __init__(self, match):
+ PinterestExtractor.__init__(self, match)
+ self.pin_id = match[1]
+ self.pin = None
+
+ def metadata(self):
+ self.pin = self.api.pin(self.pin_id)
+ return self.pin
+
+ def pins(self):
+ return (self.pin,)
+
+
+class PinterestBoardExtractor(PinterestExtractor):
+ """Extractor for images from a board from pinterest.com"""
+ subcategory = "board"
+ directory_fmt = ("{category}", "{board[owner][username]}", "{board[name]}")
+ archive_fmt = "{board[id]}_{id}"
+ pattern = (BASE_PATTERN + r"/(?!pin/)([^/?#]+)"
+ r"/([^/?#]+)/?(?!.*#related$)")
+ example = "https://www.pinterest.com/USER/BOARD/"
+
+ def __init__(self, match):
+ PinterestExtractor.__init__(self, match)
+ self.user = text.unquote(match[1])
+ self.board_name = text.unquote(match[2])
+ self.board = None
+
+ def metadata(self):
+ self.board = self.api.board(self.user, self.board_name)
+ return {"board": self.board}
+
+ def pins(self):
+ board = self.board
+ pins = self.api.board_pins(board["id"])
+
+ if board["section_count"] and self.config("sections", True):
+ base = f"{self.root}{board['url']}id:"
+ data = {"_extractor": PinterestSectionExtractor}
+ sections = [(base + section["id"], data)
+ for section in self.api.board_sections(board["id"])]
+ pins = itertools.chain(pins, sections)
+
+ return pins
+
+
class PinterestRelatedPinExtractor(PinterestPinExtractor):
"""Extractor for related pins of another pin from pinterest.com"""
subcategory = "related-pin"