From 58d97188b41bfe6c40a5e0cbe3bfabe136d3a3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 26 Oct 2022 21:28:50 +0200 Subject: [PATCH] [mastodon] add 'bookmark' extractor (#3109) --- docs/supportedsites.md | 6 +++--- gallery_dl/extractor/mastodon.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 07f5f55e..47dc5e6f 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -1242,19 +1242,19 @@ Consider all sites to be NSFW unless otherwise known. mastodon.social https://mastodon.social/ - Images from Statuses, User Profiles + Bookmarks, Images from Statuses, User Profiles OAuth Pawoo https://pawoo.net/ - Images from Statuses, User Profiles + Bookmarks, Images from Statuses, User Profiles OAuth baraag https://baraag.net/ - Images from Statuses, User Profiles + Bookmarks, Images from Statuses, User Profiles OAuth diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py index 9ce57723..296fd5f4 100644 --- a/gallery_dl/extractor/mastodon.py +++ b/gallery_dl/extractor/mastodon.py @@ -126,6 +126,20 @@ class MastodonUserExtractor(MastodonExtractor): ) +class MastodonBookmarkExtractor(MastodonExtractor): + """Extractor for mastodon bookmarks""" + subcategory = "bookmark" + pattern = BASE_PATTERN + r"/bookmarks" + test = ( + ("https://mastodon.social/bookmarks"), + ("https://pawoo.net/bookmarks"), + ("https://baraag.net/bookmarks"), + ) + + def statuses(self): + return MastodonAPI(self).account_bookmarks() + + class MastodonFollowingExtractor(MastodonExtractor): """Extractor for followed mastodon users""" subcategory = "following" @@ -204,6 +218,10 @@ class MastodonAPI(): return account["id"] raise exception.NotFoundError("account") + def account_bookmarks(self): + endpoint = "/v1/bookmarks" + return self._pagination(endpoint, None) + def account_following(self, account_id): endpoint = "/v1/accounts/{}/following".format(account_id) return self._pagination(endpoint, None)