kopia lustrzana https://codeberg.org/edent/Mastodon_Tools
Add status viewer
rodzic
1c76ca8b2c
commit
959df2c8e9
|
@ -17,3 +17,11 @@ Usage:
|
|||
`python3 threads.py https://your_mastodon.instance/@username@their.instance/1234`
|
||||
|
||||
⚠ Note! Large conversations may take a long time to retrieve from the API.
|
||||
|
||||
## Status
|
||||
|
||||
Pretty Prints (in colour!) all the data behind a status.
|
||||
|
||||
Usage:
|
||||
|
||||
`python3 status.py https://mastodon.social/@Edent/109358520333182101`
|
|
@ -0,0 +1,32 @@
|
|||
import config
|
||||
from mastodon import Mastodon
|
||||
from urllib.parse import urlparse
|
||||
import argparse
|
||||
from rich.pretty import pprint
|
||||
|
||||
# Take a command line argument. e.g. python3 threads.py https://mastodon.example/@me@somewhere/1234
|
||||
parser = argparse.ArgumentParser(description='Display the data behind a Mastodon status.')
|
||||
parser.add_argument('url', metavar='URl', type=str, help='A URl of a post on your instance of Mastodon')
|
||||
args = parser.parse_args()
|
||||
path = urlparse(args.url).path
|
||||
path_list = path.split("/")
|
||||
path_id = path_list[-1]
|
||||
|
||||
if path_id.isdigit() :
|
||||
# Status ID
|
||||
# This is the ID from *your* instance
|
||||
status_id = int(path_id)
|
||||
else :
|
||||
print("Hmmm... That doesn't look like a valid Mastodon Status URl.\n" +
|
||||
"It should look like https://mastodon.example/@me@somewhere/1234\n" +
|
||||
"The last part of the URl must be the status ID, which is a number."
|
||||
)
|
||||
exit()
|
||||
|
||||
# Set up access
|
||||
mastodon = Mastodon( api_base_url=config.instance, access_token=config.access_token )
|
||||
|
||||
# Get the status
|
||||
status = mastodon.status(status_id)
|
||||
|
||||
pprint(status)
|
Ładowanie…
Reference in New Issue