Last active
September 25, 2023 18:36
-
-
Save fabiocosta0305/42f6f74a8a7b229a2000b75a1371b71c to your computer and use it in GitHub Desktop.
Um script rápido para publicação massiva de imagens no Pixelfed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mastodon import Mastodon | |
| import os | |
| connect=Mastodon(access_token="<token>",api_base_url="<url>") | |
| dirpath="<path das imagens>" | |
| listfiles=os.listdir(dir_path) | |
| files=listfiles | |
| message="<post>" | |
| max_post=10 # por servidor, padrão do Pixelfed é 4 | |
| medias=[] | |
| while files: | |
| path=dirpath+"/"+files.pop(0) | |
| data=connect.media_post(path,'image/jpeg',message) | |
| medias.append(data['id']) | |
| if len(medias)>=max_post or files==[]: | |
| connect.status_post(message,media_ids=medias) | |
| medias=[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment