pages
Terence Eden 2022-11-16 09:59:07 +00:00
rodzic bae75de1e5
commit e64bb6adaf
1 zmienionych plików z 21 dodań i 5 usunięć

Wyświetl plik

@ -1,13 +1,29 @@
from datetime import datetime, timedelta
import config
from mastodon import Mastodon
from treelib import Node, Tree
from datetime import datetime, timedelta
from urllib.parse import urlparse
import argparse
from bs4 import BeautifulSoup
import config
# Take a command line argument. e.g. python3 threads.py https://mastodon.example/@me@somewhere/1234
parser = argparse.ArgumentParser(description='Display a tree based on a Mastodon conversation.')
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]
# Status ID
# This is the ID from *your* instance
status_id = 109343943300929632
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 )