Compare commits

..

2 Commits

Author SHA1 Message Date
8c4a36791f autoformatter says change this so i change 2022-04-06 09:44:19 +02:00
dfa4b40d52 more hashtags 2022-04-06 09:44:14 +02:00

View File

@ -21,14 +21,14 @@ hashtags = [
"lumbungkios", "lumbungkios",
"kassel_ecosystem", "kassel_ecosystem",
"ruruhaus", "ruruhaus",
"offbeatentrack_kassel" "offbeatentrack_kassel",
"lumbungofpublishers",
] ]
def login_mastodon_bot(): def login_mastodon_bot():
mastodon = Mastodon( mastodon = Mastodon(
access_token=os.environ.get("MASTODON_AUTH_TOKEN"), access_token=os.environ.get("MASTODON_AUTH_TOKEN"), api_base_url=instance
api_base_url = instance
) )
return mastodon return mastodon
@ -72,9 +72,9 @@ def create_post(post_directory, post_metadata):
template_dir = os.path.join(Path(__file__).parent.resolve(), "templates") template_dir = os.path.join(Path(__file__).parent.resolve(), "templates")
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir)) env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
name = post_metadata['account']['display_name'] name = post_metadata["account"]["display_name"]
name = sub('"', '\\"', name) name = sub('"', '\\"', name)
post_metadata['account']['display_name'] = name post_metadata["account"]["display_name"] = name
env.filters["localize_media_url"] = localize_media_url env.filters["localize_media_url"] = localize_media_url
env.filters["filter_mastodon_urls"] = filter_mastodon_urls env.filters["filter_mastodon_urls"] = filter_mastodon_urls
@ -139,7 +139,10 @@ def main():
create_post(post_dir, post_metadata) create_post(post_dir, post_metadata)
all_existing_posts.append(str(post_metadata["id"])) all_existing_posts.append(str(post_metadata["id"]))
else: else:
print("not pulling post %s (post is local only)" % (post_metadata["id"])) print(
"not pulling post %s (post is local only)"
% (post_metadata["id"])
)
# if we already have the post do nothing, possibly update # if we already have the post do nothing, possibly update
elif str(post_metadata["id"]) in existing_posts: elif str(post_metadata["id"]) in existing_posts:
@ -148,7 +151,10 @@ def main():
str(post_metadata["id"]) str(post_metadata["id"])
) # create list of posts which have not been returned in the feed ) # create list of posts which have not been returned in the feed
elif str(post_metadata["id"]) in all_existing_posts: elif str(post_metadata["id"]) in all_existing_posts:
print("skipping post %s as it was already pulled with a different hashtag." % (str(post_metadata["id"]))) print(
"skipping post %s as it was already pulled with a different hashtag."
% (str(post_metadata["id"]))
)
for post in existing_posts: for post in existing_posts:
print( print(