summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/mastodon.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-11-01 21:32:54 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-11-01 21:32:54 -0400
commite59d46ecda74190381b1d2725b0bd9df5c0be8d8 (patch)
treecff6d69d4f68ef011a496ff2311173ebef70bf3f /gallery_dl/extractor/mastodon.py
parent78e2d1672e4301497f786cd03637de9ddbc717ac (diff)
New upstream version 1.23.5.upstream/1.23.5
Diffstat (limited to 'gallery_dl/extractor/mastodon.py')
-rw-r--r--gallery_dl/extractor/mastodon.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py
index 9ce5772..0d2cded 100644
--- a/gallery_dl/extractor/mastodon.py
+++ b/gallery_dl/extractor/mastodon.py
@@ -92,7 +92,7 @@ INSTANCES = {
}
}
-BASE_PATTERN = MastodonExtractor.update(INSTANCES)
+BASE_PATTERN = MastodonExtractor.update(INSTANCES) + "(?:/web)?"
class MastodonUserExtractor(MastodonExtractor):
@@ -111,9 +111,16 @@ class MastodonUserExtractor(MastodonExtractor):
"count": 60,
}),
("https://baraag.net/@pumpkinnsfw"),
+ ("https://mastodon.social/@yoru_nine@pawoo.net", {
+ "pattern": r"https://mastodon\.social/media_proxy/\d+/original",
+ "range": "1-10",
+ "count": 10,
+ }),
("https://mastodon.social/@id:10843"),
("https://mastodon.social/users/id:10843"),
("https://mastodon.social/users/jk"),
+ ("https://mastodon.social/users/yoru_nine@pawoo.net"),
+ ("https://mastodon.social/web/@jk"),
)
def statuses(self):
@@ -126,6 +133,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"
@@ -197,13 +218,21 @@ class MastodonAPI():
if username.startswith("id:"):
return username[3:]
- handle = "@{}@{}".format(username, self.extractor.instance)
+ if "@" in username:
+ handle = "@" + username
+ else:
+ handle = "@{}@{}".format(username, self.extractor.instance)
+
for account in self.account_search(handle, 1):
- if account["username"] == username:
+ if account["acct"] == username:
self.extractor._check_move(account)
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)