[pinterest] add extractor for created pins (#2452)

This commit is contained in:
Mike Fährmann
2022-04-01 16:59:58 +02:00
parent 1171911dc3
commit 9c5d2d7af3
3 changed files with 36 additions and 2 deletions

View File

@@ -586,7 +586,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr> <tr>
<td>Pinterest</td> <td>Pinterest</td>
<td>https://www.pinterest.com/</td> <td>https://www.pinterest.com/</td>
<td>Pins, pin.it Links, related Pins, Search Results, Sections, User Profiles</td> <td>Created Pins, Pins, pin.it Links, related Pins, Search Results, Sections, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td> <td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td>
</tr> </tr>
<tr> <tr>

View File

@@ -123,7 +123,8 @@ class PinterestBoardExtractor(PinterestExtractor):
subcategory = "board" subcategory = "board"
directory_fmt = ("{category}", "{board[owner][username]}", "{board[name]}") directory_fmt = ("{category}", "{board[owner][username]}", "{board[name]}")
archive_fmt = "{board[id]}_{id}" archive_fmt = "{board[id]}_{id}"
pattern = BASE_PATTERN + r"/(?!pin/)([^/?#&]+)/(?!_saved)([^/?#&]+)/?$" pattern = (BASE_PATTERN + r"/(?!pin/)([^/?#&]+)"
"/(?!_saved|_created)([^/?#&]+)/?$")
test = ( test = (
("https://www.pinterest.com/g1952849/test-/", { ("https://www.pinterest.com/g1952849/test-/", {
"pattern": r"https://i\.pinimg\.com/originals/", "pattern": r"https://i\.pinimg\.com/originals/",
@@ -191,6 +192,28 @@ class PinterestUserExtractor(PinterestExtractor):
yield Message.Queue, self.root + url, board yield Message.Queue, self.root + url, board
class PinterestCreatedExtractor(PinterestExtractor):
"""Extractor for a user's created pins"""
subcategory = "created"
directory_fmt = ("{category}", "{user}")
pattern = BASE_PATTERN + r"/(?!pin/)([^/?#&]+)/_created/?$"
test = ("https://www.pinterest.com/amazon/_created", {
"pattern": r"https://i\.pinimg\.com/originals/[0-9a-f]{2}"
r"/[0-9a-f]{2}/[0-9a-f]{2}/[0-9a-f]{32}\.jpg",
"count": 2,
})
def __init__(self, match):
PinterestExtractor.__init__(self, match)
self.user = text.unquote(match.group(1))
def metadata(self):
return {"user": self.user}
def pins(self):
return self.api.user_activity_pins(self.user)
class PinterestSectionExtractor(PinterestExtractor): class PinterestSectionExtractor(PinterestExtractor):
"""Extractor for board sections on pinterest.com""" """Extractor for board sections on pinterest.com"""
subcategory = "section" subcategory = "section"
@@ -384,6 +407,16 @@ class PinterestAPI():
options = {"board_id": board_id, "add_vase": True} options = {"board_id": board_id, "add_vase": True}
return self._pagination("BoardRelatedPixieFeed", options) return self._pagination("BoardRelatedPixieFeed", options)
def user_activity_pins(self, user):
"""Yield pins created by 'user'"""
options = {
"exclude_add_pin_rep": True,
"field_set_key" : "grid_item",
"is_own_profile_pins": False,
"username" : user,
}
return self._pagination("UserActivityPins", options)
def search(self, query): def search(self, query):
"""Yield pins from searches""" """Yield pins from searches"""
options = {"query": query, "scope": "pins", "rs": "typed"} options = {"query": query, "scope": "pins", "rs": "typed"}

View File

@@ -180,6 +180,7 @@ SUBCATEGORY_MAP = {
"pinterest": { "pinterest": {
"board": "", "board": "",
"pinit": "pin.it Links", "pinit": "pin.it Links",
"created": "Created Pins",
}, },
"pixiv": { "pixiv": {
"me" : "pixiv.me Links", "me" : "pixiv.me Links",