Begin work on Mastodon/Pixelfed publishing

This commit is contained in:
Fred Boniface 2023-11-05 15:21:52 +00:00
parent 71c9675059
commit 41f0a5c31f
5 changed files with 15 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import pyexiv2
def get_image_data(path: str):
print(f"Opening file: {path}")
print(f"Reading metadata: {path}")
img = pyexiv2.Image(path)
xmp = img.read_xmp()
create_date = xmp.get('Xmp.xmp.CreateDate', 'N/A')

View File

@ -2,4 +2,3 @@ import os, toml
from dotenv import load_dotenv
config = toml.load("conf.toml")
print(config)

View File

@ -37,9 +37,14 @@ def main():
file_data.append(item_data)
if load_config.config['flickr']['enable']:
print("Flickr publishing enabled")
import publish_flickr
publish_flickr.upload(file_data)
if load_config.config['pixelfed']['enable']:
print("Pixelfed publishing enabled")
import publish_pixelfed
def list_files_in_directory(directory):
top_level_items = os.listdir(directory)
full_paths = [os.path.join(directory, item) for item in top_level_items]

View File

@ -7,7 +7,6 @@ flickr.authenticate_via_browser(perms='write')
def upload(file_data: list):
for file in file_data:
print(file)
flickr.upload(
filename = file['path'],
title = file['title'],

8
publish_pixelfed.py Normal file
View File

@ -0,0 +1,8 @@
import load_config
from mastodon import Mastodon
Mastodon.create_app("social_photos", api_base_url=load_config.config['pixelfed']['server'], user_agent="social-photos")
Mastodon.log_in(code=load_config['pixelfed']['token'])
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')