From 24dd10ac3c03b4d09d1c74fc7f781265b9ab4955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 18 May 2021 00:31:01 +0200 Subject: [PATCH] [patreon] extract user defined 'tags' (#1539, closes #1540) --- gallery_dl/extractor/patreon.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/patreon.py b/gallery_dl/extractor/patreon.py index 839e0b85..9c32d7aa 100644 --- a/gallery_dl/extractor/patreon.py +++ b/gallery_dl/extractor/patreon.py @@ -117,12 +117,22 @@ class PatreonExtractor(Extractor): attr = post["attributes"] attr["id"] = text.parse_int(post["id"]) - if post.get("current_user_can_view", True): + if attr.get("current_user_can_view", True): + + relationships = post["relationships"] attr["images"] = self._files(post, included, "images") attr["attachments"] = self._files(post, included, "attachments") attr["date"] = text.parse_datetime( attr["published_at"], "%Y-%m-%dT%H:%M:%S.%f%z") - user = post["relationships"]["user"] + + tags = relationships.get("user_defined_tags") + attr["tags"] = [ + tag["id"].replace("user_defined;", "") + for tag in tags["data"] + if tag["type"] == "post_tag" + ] if tags else [] + + user = relationships["user"] attr["creator"] = ( self._user(user["links"]["related"]) or included["user"][user["data"]["id"]]) @@ -299,6 +309,10 @@ class PatreonPostExtractor(PatreonExtractor): ("https://www.patreon.com/posts/19987002", { "count": 4, }), + # tags (#1539) + ("https://www.patreon.com/posts/free-post-12497641", { + "keyword": {"tags": ["AWMedia"]}, + }), ("https://www.patreon.com/posts/not-found-123", { "exception": exception.NotFoundError, }),