Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media_update return Error 404: Record not found #358

Open
retiolus opened this issue Oct 8, 2023 · 4 comments
Open

media_update return Error 404: Record not found #358

retiolus opened this issue Oct 8, 2023 · 4 comments

Comments

@retiolus
Copy link

retiolus commented Oct 8, 2023

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..."

@halcy
Copy link
Owner

halcy commented Oct 9, 2023

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.

@ianh
Copy link

ianh commented Jun 18, 2024

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.

@ianh
Copy link

ianh commented Jun 18, 2024

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.

@ianh
Copy link

ianh commented Jun 18, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants