Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
subtitle_base = client.streaming.videos.subtitles.update(
id=0,
video_id=0,
)
print(subtitle_base.language)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
"github.com/G-Core/gcore-go/streaming"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
subtitleBase, err := client.Streaming.Videos.Subtitles.Update(
context.TODO(),
0,
streaming.VideoSubtitleUpdateParams{
VideoID: 0,
SubtitleBase: streaming.SubtitleBaseParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", subtitleBase.Language)
}
curl --request PATCH \
--url https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"language": "ltz"
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({language: 'ltz'})
};
fetch('https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'language' => 'ltz'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"language\": \"ltz\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"language\": \"ltz\"\n}"
response = http.request(request)
puts response.read_body{
"name": "German (AI-generated)",
"language": "ltz",
"vtt": "WEBVTT 1 00:00:07.154 --> 00:00:12.736 Wir haben 100 Millionen registrierte Benutzer oder aktive Benutzer, die mindestens einmal pro Woche spielen.\n2 00:00:13.236 --> 00:00:20.198 Wir haben vielleicht 80 oder 100.000, die auf einem bestimmten Cluster spielen."
}{
"status": 404,
"error": "Not Found. Entity you are looking for was not found, please check the initial parameters"
}{
"status": 422,
"error": "Unprocessable Entity. Language code is not recognized."
}Subtitles
Change subtitle
Method to update subtitle of a video.
You can update all or only some of fields you need.
If you want to replace the text of subtitles (i.e. found a typo in the text, or the timing in the video changed), then:
- download it using GET method,
- change it in an external editor,
- and update it using this PATCH method.
Just like videos, subtitles are cached, so it takes time to update the data. See POST method for details.
PATCH
/
streaming
/
videos
/
{video_id}
/
subtitles
/
{id}
Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
subtitle_base = client.streaming.videos.subtitles.update(
id=0,
video_id=0,
)
print(subtitle_base.language)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
"github.com/G-Core/gcore-go/streaming"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
subtitleBase, err := client.Streaming.Videos.Subtitles.Update(
context.TODO(),
0,
streaming.VideoSubtitleUpdateParams{
VideoID: 0,
SubtitleBase: streaming.SubtitleBaseParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", subtitleBase.Language)
}
curl --request PATCH \
--url https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"language": "ltz"
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({language: 'ltz'})
};
fetch('https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'language' => 'ltz'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"language\": \"ltz\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/streaming/videos/{video_id}/subtitles/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"language\": \"ltz\"\n}"
response = http.request(request)
puts response.read_body{
"name": "German (AI-generated)",
"language": "ltz",
"vtt": "WEBVTT 1 00:00:07.154 --> 00:00:12.736 Wir haben 100 Millionen registrierte Benutzer oder aktive Benutzer, die mindestens einmal pro Woche spielen.\n2 00:00:13.236 --> 00:00:20.198 Wir haben vielleicht 80 oder 100.000, die auf einem bestimmten Cluster spielen."
}{
"status": 404,
"error": "Not Found. Entity you are looking for was not found, please check the initial parameters"
}{
"status": 422,
"error": "Unprocessable Entity. Language code is not recognized."
}Authorizations
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234_abcdef
Body
application/json
Was this page helpful?