|
|
@ -6,27 +6,40 @@ import datetime
|
|
|
|
#toots id and instances position refer to same post
|
|
|
|
#toots id and instances position refer to same post
|
|
|
|
#FOR EXAMPLE
|
|
|
|
#FOR EXAMPLE
|
|
|
|
#toot_id[0] goes with instances[0]
|
|
|
|
#toot_id[0] goes with instances[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# IMPORTANT: Ensure the order of elements in toot_id and instances
|
|
|
|
|
|
|
|
# Are the same as the order of the tokens tokens.txt
|
|
|
|
toot_id = [101767654564328802, 101767613341391125]
|
|
|
|
toot_id = [101767654564328802, 101767613341391125]
|
|
|
|
instances = ["https://todon.nl/", "https://meow.social/"]
|
|
|
|
instances = ["https://todon.nl/", "https://meow.social/"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ok, estou a ver o problem. Cada token correspond a uma instancia
|
|
|
|
|
|
|
|
# de forma mas ter que ter a mesma order de instances na lista e de tokens em token.txt
|
|
|
|
|
|
|
|
# para isso podemos usar enumerate() no for loop
|
|
|
|
|
|
|
|
# utilizando a variavel n (numero da iteração) para determinar qual dos items de instances,
|
|
|
|
|
|
|
|
# é a instance de aquele token
|
|
|
|
|
|
|
|
# Outro problem: token.readlines() acrescenta um line break ao token: \n
|
|
|
|
|
|
|
|
# deforma the of temos que remove em access_token=token_line.replace('\n','')
|
|
|
|
|
|
|
|
|
|
|
|
#toots token order is also the same
|
|
|
|
#toots token order is also the same
|
|
|
|
#FOR EXAMPLE
|
|
|
|
#FOR EXAMPLE
|
|
|
|
#toot_id[0] goes with instances[0] and now goes with line nr1 from txt file
|
|
|
|
#toot_id[0] goes with instances[0] and now goes with line nr1 from txt file
|
|
|
|
with open('token.txt', 'r') as token:
|
|
|
|
with open('token.txt', 'r') as token:
|
|
|
|
for token_line in token.readlines():
|
|
|
|
for n, token_line in enumerate(token.readlines()):
|
|
|
|
print(token_line)
|
|
|
|
base_url = instances[n]
|
|
|
|
for base_url in instances:
|
|
|
|
print(token_line, base_url)
|
|
|
|
print(str(base_url))
|
|
|
|
# token_line é uma das linhas de token.txt
|
|
|
|
mastodon = Mastodon(access_token=token.read(),api_base_url=(str(base_url)))
|
|
|
|
# como a les em token.readlines() n precisas de ler outra ver
|
|
|
|
|
|
|
|
# e podes usar apenas a var token_line
|
|
|
|
for id in toot_id:
|
|
|
|
mastodon = Mastodon(access_token=token_line.replace('\n', ''),
|
|
|
|
descendants = mastodon.status_context(id=(toot_id))["descendants"]
|
|
|
|
api_base_url=(str(base_url)))
|
|
|
|
print(toot_id)
|
|
|
|
toot_id_current = toot_id[n]
|
|
|
|
time.sleep(1)
|
|
|
|
print(toot_id_current)
|
|
|
|
|
|
|
|
status = mastodon.status_context(id=(toot_id_current))
|
|
|
|
|
|
|
|
descendants = mastodon.status_context(id=(toot_id_current))["descendants"]
|
|
|
|
|
|
|
|
print(toot_id_current)
|
|
|
|
for answer in descendants:
|
|
|
|
for answer in descendants:
|
|
|
|
pprint(answer["id"])
|
|
|
|
pprint(answer["id"])
|
|
|
|
#geral = mastodon.status(answer["id"]))
|
|
|
|
# geral = mastodon.status(answer["id"]))
|
|
|
|
avatar = mastodon.status(answer["id"])['account']['avatar']
|
|
|
|
avatar = mastodon.status(answer["id"])['account']['avatar']
|
|
|
|
name = mastodon.status(answer["id"])['account']['display_name']
|
|
|
|
name = mastodon.status(answer["id"])['account']['display_name']
|
|
|
|
bot = mastodon.status(answer["id"])['account']['bot']
|
|
|
|
bot = mastodon.status(answer["id"])['account']['bot']
|
|
|
|