I keep encountering the same error when attempting to automate video publishing on PeerTube using Python. Can anyone help me troubleshoot this

Hello, I want to set up a Python script that will automatically publish my video stock from a folder using the PeerTube API. I tried with Postman and it’s working, but when I want to automate this with Python, I encounter the same error. I’ve really tried to search for a solution by myself, but I couldn’t figure out why I always get error 415, because I’m sure my video is in .mp4 format. Maybe my PeerTube server isn’t properly configured. If you can help me, thank you.

You may get help from this existing python script? LecygneNoir/prismedia: Scripting way to upload videos to peertube and youtube - prismedia/pt_upload.py at master - prismedia - Gitea: Git Service for LecygneNoir

I don’t know Python, but i think it is because you don’t attach a MIME type to your videofile field.

See here, for a similar issue in NodeJS: Best way to upload 30k videos? - #24 par GregRc

This seems to be done in the script mentionned by Chocobozzz, using this function:

    def get_file(path):
        mimetypes.init()
        return (basename(path), open(abspath(path), 'rb'),
                mimetypes.types_map[splitext(path)[1]])

It’s woorking tank you very much it’s definitly the MIME type

1 Like

So you can mark the subject as solved (there should be a button under my message, or chocobozzz’s message, to mark it as the solution)