Skip to content

Commit

Permalink
[mastodon] support cross-instance user references (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 29, 2022
1 parent 4877176 commit 4dde59e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gallery_dl/extractor/mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ class MastodonUserExtractor(MastodonExtractor):
"count": 60,
}),
("https://baraag.net/@pumpkinnsfw"),
("https://mastodon.social/@[email protected]", {
"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/[email protected]"),
)

def statuses(self):
Expand Down Expand Up @@ -211,9 +217,13 @@ def account_id_by_username(self, username):
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")
Expand Down

0 comments on commit 4dde59e

Please sign in to comment.