1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[mastodon] add 'bookmark' extractor (#3109)

This commit is contained in:
Mike Fährmann 2022-10-26 21:28:50 +02:00
parent c8af1f585a
commit 58d97188b4
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 21 additions and 3 deletions

View File

@ -1242,19 +1242,19 @@ Consider all sites to be NSFW unless otherwise known.
<tr>
<td>mastodon.social</td>
<td>https://mastodon.social/</td>
<td>Images from Statuses, User Profiles</td>
<td>Bookmarks, Images from Statuses, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a></td>
</tr>
<tr>
<td>Pawoo</td>
<td>https://pawoo.net/</td>
<td>Images from Statuses, User Profiles</td>
<td>Bookmarks, Images from Statuses, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a></td>
</tr>
<tr>
<td>baraag</td>
<td>https://baraag.net/</td>
<td>Images from Statuses, User Profiles</td>
<td>Bookmarks, Images from Statuses, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a></td>
</tr>

View File

@ -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)