-
-
Notifications
You must be signed in to change notification settings - Fork 939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mastodon] add "instance_remote" field #3119
Conversation
gallery_dl/extractor/mastodon.py
Outdated
if "@" in status["account"]["acct"]: | ||
status["remote_instance"] = status["account"]["acct"].split('@')[1] | ||
else: | ||
status["remote_instance"] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "@" in status["account"]["acct"]: | |
status["remote_instance"] = status["account"]["acct"].split('@')[1] | |
else: | |
status["remote_instance"] = None | |
acct = status["account"]["acct"] | |
status["remote_instance"] = \ | |
acct.rpartition("@")[2] if "@" in acct else None |
- Accessing
status["account"]["acct"]
multiple times is slower than storing it in a local variable - I prefer (r)partition over split. It's usually even faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for you suggestions. I had messed up flake8 with GH GUI.
Do you think it'd be better to call this field And what about only defining it when a post/status is from a remote instance? |
That is also fine.
Would that hide the field from the |
It would ... OK, lets forget about that idea then. |
Example Usage: If the url is ```"mastodon:https://mastodon.example.org/@[email protected] the "remote_instance" will be "botsin.space" ... "directory": ["mastodon", "{remote_instance|instance}", "{account[username]!l}"] ...
3800491
to
095c75e
Compare
Example usage:
If the url is
mastodon:https://social.linux.pizza/@[email protected]
the "remote_instance" will be "botsin.space".
"directory": ["mastodon", "{instance_remote|instance}", "{account[username]!l}"]