diff options
Diffstat (limited to 'gallery_dl/extractor/mastodon.py')
| -rw-r--r-- | gallery_dl/extractor/mastodon.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py index e49d29a..e190c7e 100644 --- a/gallery_dl/extractor/mastodon.py +++ b/gallery_dl/extractor/mastodon.py @@ -227,6 +227,12 @@ class MastodonAPI(): if username.startswith("id:"): return username[3:] + try: + return self.account_lookup(username)["id"] + except Exception: + # fall back to account search + pass + if "@" in username: handle = "@" + username else: @@ -246,6 +252,11 @@ class MastodonAPI(): endpoint = "/v1/accounts/{}/following".format(account_id) return self._pagination(endpoint, None) + def account_lookup(self, username): + endpoint = "/v1/accounts/lookup" + params = {"acct": username} + return self._call(endpoint, params).json() + def account_search(self, query, limit=40): """Search for accounts""" endpoint = "/v1/accounts/search" |
