Mastodon reblog should be complete
This commit is contained in:
parent
cec8ea0576
commit
7e78c1c5f0
@ -5,7 +5,13 @@ from mastodon import Mastodon
|
|||||||
m = Mastodon(access_token=config['boost_mastodon']['token'], api_base_url=config['boost_mastodon']['server'])
|
m = Mastodon(access_token=config['boost_mastodon']['token'], api_base_url=config['boost_mastodon']['server'])
|
||||||
|
|
||||||
def boost(url):
|
def boost(url):
|
||||||
url = "pixelfed.scot/i/web/post/626860160148125215"
|
url = "https://pixelfed.scot/i/web/post/626007326735984162"
|
||||||
search_results = m.search(url, resolve=True)
|
search_results = m.search(url, resolve=True, exclude_unreviewed=False)
|
||||||
print(search_results)
|
status_result_count = len(search_results['statuses'])
|
||||||
print("Error with searching")
|
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)
|
||||||
|
@ -9,14 +9,14 @@ def upload(file_data: list):
|
|||||||
print("Uploading image to Pixelfed")
|
print("Uploading image to Pixelfed")
|
||||||
media_upload = m.media_post(file['path'], "image/jpeg")
|
media_upload = m.media_post(file['path'], "image/jpeg")
|
||||||
print("Posting to Pixelfed")
|
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']
|
return post_upload['url']
|
||||||
|
|
||||||
def formatPost(file: dict):
|
def formatPost(file: dict):
|
||||||
tag_string = formatTags(file['tags'])
|
tag_string = formatTags(file['tags'])
|
||||||
if load_config.config['pixelfed']['add_to_description']:
|
if load_config.config['pixelfed']['add_to_description']:
|
||||||
file['description'] = file['description'] + 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):
|
def formatTags(tags: list):
|
||||||
formatted_tags = ['#' + tag.title().replace(' ', '') for tag in tags]
|
formatted_tags = ['#' + tag.title().replace(' ', '') for tag in tags]
|
||||||
|
Loading…
Reference in New Issue
Block a user