forked from ruangrupa/konfluks
feat: pull posts from mastodon
This commit is contained in:
@ -14,15 +14,8 @@ hashtags = ["jalansesama"]
|
||||
|
||||
def login_mastodon_bot():
|
||||
mastodon = Mastodon(
|
||||
client_id="publishbot_clientcred.secret",
|
||||
api_base_url=instance,
|
||||
)
|
||||
|
||||
mastodon.log_in(
|
||||
email,
|
||||
password,
|
||||
to_file="publishbot_usercred.secret",
|
||||
scopes=["read"],
|
||||
access_token=os.environ.get("MASTODON_AUTH_TOKEN"),
|
||||
api_base_url = instance
|
||||
)
|
||||
|
||||
return mastodon
|
||||
@ -98,7 +91,6 @@ def filter_mastodon_urls(content):
|
||||
|
||||
def main():
|
||||
mastodon = login_mastodon_bot()
|
||||
|
||||
output_dir = os.environ.get("OUTPUT_DIR")
|
||||
if not os.path.exists(output_dir):
|
||||
os.mkdir(output_dir)
|
||||
@ -128,6 +120,8 @@ def main():
|
||||
"local_only"
|
||||
]: # if you get an error here then you are using vanilla Mastodon, this is a Hometown or Glitch only feature
|
||||
create_post(post_dir, post_metadata)
|
||||
else:
|
||||
print("not pulling post %s (post is local only)" % (post_metadata["id"]))
|
||||
|
||||
# if we already have the post do nothing, possibly update
|
||||
elif str(post_metadata["id"]) in existing_posts:
|
||||
|
Reference in New Issue
Block a user