diff options
| author | 2023-04-25 21:32:02 -0400 | |
|---|---|---|
| committer | 2023-04-25 21:32:02 -0400 | |
| commit | f98ab7aaca3c4acbd5a793267791749740330e9c (patch) | |
| tree | 72e3d3312a8ff2cdb24353b1d7be6fb8301f431c /gallery_dl/extractor/mastodon.py | |
| parent | 09e426350409d45e7f7a8ff369f8d8aa9eec0fe4 (diff) | |
New upstream version 1.25.2.upstream/1.25.2
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" |
