I have a word which is often confused with another in the auto-captioning produced by Kaltura. For example, the word “Arup” gets confused with “Arab”, understandably. I would like to automate the process of correcting the word Arab to Arup. It seems to be possible in the KMC to find and replace words in the captions, is it possible to do the same via the API?
A process along the lines of, for a media space video, get the captions, do some alterations, and make another call to the API to update with the altered version.
In general, anything that can be done using Kaltura’s web I/Fs (KMS, KMC, editing app, etc) can be done using the API and in fact, the Kaltura interfaces also invoke the same API actions to get the job done.
I have looked at the captionAsset endpoint and I am confused about how I get the captionAssetId for the .get endpoint. In the .list endpoint I can add a filter on entryIdEqual but for some reason, this returns empty. I tried it with a video ID that I know has captions.
The below code returns the expected result for me (one captionasset object) so my guess would be you’ve neglected to set disableentitlement when generating the KS…
from KalturaClient import *
from KalturaClient.Plugins.Core import *
from pprint import pprint
config = KalturaConfiguration()
config.serviceUrl = "https://www.kaltura.com/"
client = KalturaClient(config)
ks = client.generateSessionV2(
"ADMIN_SECRET",
"YOUR_USER_ID",
KalturaSessionType.ADMIN,
PARNTER_ID,86400,'disableentitlement')
client.setKs(ks)
filter = KalturaAssetFilter()
filter.entryIdEqual = "1_3bux4j0v"
pager = KalturaFilterPager()
result = client.caption.captionAsset.list(filter, pager)
for obj in result.objects:
pprint(vars(obj))
I managed to fix it, it was because I was running it on the web API, and then when I tried it with disable entitlement on my PC I was using the wrong credentials
So using your code I am able to get the caption asset ID, and with this, I can make a request to captionAsset.get which returns…
To obtain the caption asset, use captionasset.serve(), to update it, call captionasset.setContent().
If you want to update the transcript as well, use the same actions but of the attachmentasset service.
client = auth(secret, partner_id, user_id, service_url, privileges)
filter = KalturaAssetFilter()
filter.entryIdEqual = "1_3bux4j0v"
pager = KalturaFilterPager()
result = client.caption.captionAsset.list(filter, pager)
for id in result.objects[0].associatedTranscriptIds.split(","):
serve_options = KalturaAttachmentServeOptions()
r = client.attachment.attachmentAsset.serve(id, serve_options)
pprint(r)
I get the output in the form of two URLs which both give me the below error… do I need to configure the KalturaAttachmentServeOptions() or is it do with the URL formatting?
There’s no need to set/pass a KalturaAttachmentServeOptions object.
When I run the below code, I get two valid URLs that return the text in the transcript:
filter = KalturaAssetFilter()
filter.entryIdEqual = "1_3bux4j0v"
pager = KalturaFilterPager()
result = client.caption.captionAsset.list(filter, pager)
for id in result.objects[0].associatedTranscriptIds.split(","):
r = client.attachment.attachmentAsset.serve(id)
pprint(r)
If you’re not, please send me a private message with the URLs you get back and we can debug further.