FMN picture uploading

This commit is contained in:
localhost_frssoft 2022-09-01 02:06:06 +03:00
parent 6033095e89
commit 099285c147
4 changed files with 23 additions and 9 deletions

View file

@ -35,7 +35,7 @@ def get_status(status_id):
return r.json()
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600):
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600, attachments=None):
poll = None
if poll_options is not None:
poll = {
@ -43,14 +43,28 @@ def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=3
"expires_in": poll_expires,
"multiple": True
}
print(poll_options)
params = {
"status": text,
"in_reply_to_id": reply_to_status_id,
"visibility": "unlisted",
"content_type": "text/plain",
"language": "ru",
"poll": poll
}
if attachments:
params['media_ids'] = attachments
r = requests.post(instance_point + "/statuses", json=params, headers=headers)
return r.json()
def upload_attachment(file_path):
file = {
"file": open(file_path, mode='rb')
}
params = {
"description": "Fediverse Movie Night\nВоскресенье, 21:00\nLIVE ON XXIV Production",
}
r = requests.post(instance_point + "/media", params, files=file, headers=headers)
return r.json()['id']