Begin mastodon boost implementation

This commit is contained in:
Fred Boniface 2023-11-05 21:13:57 +00:00
parent 23635d8fcc
commit cec8ea0576
4 changed files with 27 additions and 3 deletions

11
boost_mastodon.py Normal file
View File

@ -0,0 +1,11 @@
from load_config import config
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")

16
main.py
View File

@ -44,15 +44,27 @@ def main():
item_data = image_processing.get_image_data(item)
file_data.append(item_data)
# Collection of post URL's which can be used for sharing features
# Where the API used doesn't support responding with a URL, a status
# message is provided.
posts = {}
if load_config.config['flickr']['enable']:
print("Flickr publishing enabled")
import publish_flickr
publish_flickr.upload(file_data)
posts['flickr'] = publish_flickr.upload(file_data)
if load_config.config['pixelfed']['enable']:
print("Pixelfed publishing enabled")
import publish_pixelfed
publish_pixelfed.upload(file_data)
posts['pixelfed'] = publish_pixelfed.upload(file_data)
if load_config.config['boost_mastodon']['enable']:
print("Mastodon Boost enabled")
import boost_mastodon
# TESTING CALL:
boost_mastodon.boost("e")
#posts['mastodon_boost'] = boost_mastodon.boost(posts['pixelfed'])
def list_files_in_directory(directory):
top_level_items = os.listdir(directory)

0
publish_facebook.py Normal file
View File

View File

@ -2,7 +2,7 @@ import load_config
from mastodon import Mastodon
m = Mastodon(access_token=load_config.config['pixelfed']['token'], api_base_url="https://pixelfed.scot")
m = Mastodon(access_token=load_config.config['pixelfed']['token'], api_base_url=load_config.config['pixelfed']['server'])
def upload(file_data: list):
for file in file_data:
@ -10,6 +10,7 @@ def upload(file_data: list):
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'])
return post_upload['url']
def formatPost(file: dict):
tag_string = formatTags(file['tags'])