FIRST - correcting already added captions (in API its call: texttracks
)
Documentation: https://developer.vimeo.com/api/upload/texttracks#uploading-a-text-track-step-1
Python example
You need to have two items:
video
JSON object (to get uri
to the video: video['uri']
) - or directly change video['uri']
in this example to uri you have
- Auth token (as
auth_token
)
How final function will look:
video = {"uri": "/videos/0000000"}
set_video_texttracks_inactive(video)
Get active texttracks for video:
def get_texttracks_uris(video):
texttracks_uris = []
video_url_tt = f"https://api.vimeo.com/{video['uri']}/texttracks"
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {auth_token}'
}
response = requests.request("GET", video_url_tt, headers=headers)
data = json.loads(response.text)
for textrack in data['data']:
if textrack['active']:
texttracks_uris.append(textrack['uri'])
print(f"Found: {len(texttracks_uris)} texttracks for video {video['uri']}")
return texttracks_uris
Disable all texttracks example function:
def set_video_texttracks_inactive(video):
texttrack_uris = get_texttracks_uris(video)
if not texttrack_uris:
print(f"No TEXTTRACKS uris found for video {video['uri']}")
else:
for texttrack_uri in texttrack_uris:
url = f"https://api.vimeo.com/{texttrack_uri}"
payload = "{ \r\n \"active\": false \r\n}"
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {auth_token}'
}
response = requests.request("PATCH", url, headers=headers, data=payload)
message = 'SETTING VIDEO TEXTTRACKS TO FALSE \n'
message += f'resp: {response.status_code} \n'
message += f'url: {url} \n'
print(message)
SECOND - is good to disable that feature in your account:
https://vimeo.zendesk.com/hc/en-us/articles/224968828-Captions-and-subtitles#h_01FTGQWR58905Z6HGPS6F6KYSS
- Navigate to the Upload defaults section of your account settings.
- By default, “Allow viewers to enable automatically generated captions” will be checked. Uncheck the box to turn this off.
- Click Save.
- Your videos will still be transcribed on the backend, but the captions will not be available to your viewers on future uploads unless you enable them on a specific video (read below).