Mastodon reblog should be complete

This commit is contained in:
Fred Boniface 2023-11-05 21:51:57 +00:00
parent cec8ea0576
commit 7e78c1c5f0
2 changed files with 12 additions and 6 deletions

View File

@ -5,7 +5,13 @@ from mastodon import Mastodon
m = Mastodon(access_token=config['boost_mastodon']['token'], api_base_url=config['boost_mastodon']['server'])
def boost(url):
url = "pixelfed.scot/i/web/post/626860160148125215"
search_results = m.search(url, resolve=True)
print(search_results)
print("Error with searching")
url = "https://pixelfed.scot/i/web/post/626007326735984162"
search_results = m.search(url, resolve=True, exclude_unreviewed=False)
status_result_count = len(search_results['statuses'])
if status_result_count != 1:
print("Unable to find status to boost")
return None
status_id = search_results['statuses'][0]['id']
print(f"Boosting status: {status_id}")
m.status_reblog(status_id, visibility="public")
m.status_favourite(status_id)

View File

@ -9,14 +9,14 @@ def upload(file_data: list):
print("Uploading image to Pixelfed")
media_upload = m.media_post(file['path'], "image/jpeg")
print("Posting to Pixelfed")
post_upload = m.status_post(formatPost(file), media_ids = media_upload['id'])
post_upload = m.status_post(formatPost(file), media_ids = media_upload['id'], visibility="public")
return post_upload['url']
def formatPost(file: dict):
tag_string = formatTags(file['tags'])
if load_config.config['pixelfed']['add_to_description']:
file['description'] = file['description'] + load_config.config['pixelfed']['add_to_description']
return f"{file['title']} | {file['description']}\n{tag_string}" # Date needs adding
return f"{file['title']} | {file['description']}<br><br>{tag_string}" # Date needs adding
def formatTags(tags: list):
formatted_tags = ['#' + tag.title().replace(' ', '') for tag in tags]