Open retiolus opened 9 months ago
Hey, I don't think we've implemented editing for media dicts yet - sorry. I've been quite busy, as is tradition, with all kinds of other things - I hope to get to Mastopy again sometime soon.
According to the API docs, PUT /api/v1/media/:id
only works before the media has been attached to a status. After that, you have to do a status update with PUT /api/v1/statuses/:id
to update the media.
Just leaving notes from my own investigation here in case they're useful. This is a real live request body from the Mastodon web UI that updates a media description: {"status":"","in_reply_to_id":null,"media_ids":["112638435710699941"],"media_attributes":[{"id":"112638435710699941","description":"test","focus":"0.00,0.00"}],"sensitive":false,"spoiler_text":"","visibility":"public","poll":null,"language":"en"}
. There doesn't seem to be a way to set media_attributes
from the mastodon.py status_update
function, however.
Here's the working code I ended up with (given a status
, an attachment_id
, and a description
):
source = mc.status_source(status.id)
source['status'] = source['text']
del source['text']
source['media_ids'] = list(map(lambda a: str(a.id), status.media_attachments))
source['media_attributes'] = [{
'id': attachment_id,
'description': description,
}]
mc._Mastodon__api_request('PUT', '/api/v1/statuses/{0}'.format(str(status.id)), source, use_json=True)
Hi, I'm trying to update media description of an uploaded image, I get its id from the status dict but media_update always returns "Record not found..."