I’m trying to upload captions to videos using the requests library in python3 using the following function.
def upload_captions(CF_VIDEO_URL, caption_file, caption_language):
# Uploads and associates caption_file with CF_VIDEO_URL
files = {
'file': open(caption_file, 'rb')
}
r = requests.put(f"{config.CF_API_ENDPOINT}/accounts/{config.CF_ACCOUNT_ID}/stream/{CF_VIDEO_URL}/captions/{caption_language}",
headers=config.CF_HEADERS, files=files)
parsed = json.loads(r.text)
I’m logging the response in my dev environment, where I get am HTTP 400 and the following json returned:
{'result': None, 'success': False, 'errors': [{'code': 10004, 'message': 'Decoding Error'}], 'messages': None}
I’ve confirmed that the .vtt file I’m using is valid by associating it with the test video manually, and I assume that the upload URL is well-formed, given that it’s the same basic URL that I’m successfully using to upload videos with the requests library.