From bf70b5ad44b3f50746cc28521abae49aa6530384 Mon Sep 17 00:00:00 2001 From: olivierapivideo Date: Tue, 8 Oct 2024 09:14:38 +0000 Subject: [PATCH] Add transcript feature --- CHANGELOG.md | 3 + docs/model/Video.md | 11 ++++ docs/model/VideoCreationPayload.md | 42 ++++++++++++++ docs/model/VideoUpdatePayload.md | 42 ++++++++++++++ package.json | 2 +- src/HttpClient.ts | 2 +- src/ObjectSerializer.ts | 3 + src/model/Video.ts | 22 ++++++++ src/model/VideoCreationPayload.ts | 55 +++++++++++++++++++ src/model/VideoUpdatePayload.ts | 55 +++++++++++++++++++ test/payloads/videos/create/responses201.json | 2 + ...{responses400.json => responses400-0.json} | 0 .../videos/create/responses400-1.json | 7 +++ .../videos/create/responses400-2.json | 7 +++ test/payloads/videos/get/responses200.json | 2 + test/payloads/videos/list/responses200.json | 6 ++ test/payloads/videos/update/responses200.json | 2 + ...{responses400.json => responses400-0.json} | 0 .../videos/update/responses400-1.json | 7 +++ .../videos/update/responses400-2.json | 7 +++ .../uploadWithUploadToken/responses201.json | 1 + 21 files changed, 276 insertions(+), 2 deletions(-) rename test/payloads/videos/create/{responses400.json => responses400-0.json} (100%) create mode 100644 test/payloads/videos/create/responses400-1.json create mode 100644 test/payloads/videos/create/responses400-2.json rename test/payloads/videos/update/{responses400.json => responses400-0.json} (100%) create mode 100644 test/payloads/videos/update/responses400-1.json create mode 100644 test/payloads/videos/update/responses400-2.json diff --git a/CHANGELOG.md b/CHANGELOG.md index b69c7e9..9747c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [2.6.4] - 2024-10-08 +- Add transcript feature + ## [2.6.3] - 2024-09-30 - Add /tags API endpoint diff --git a/docs/model/Video.md b/docs/model/Video.md index 33d40b7..0c6203b 100644 --- a/docs/model/Video.md +++ b/docs/model/Video.md @@ -14,6 +14,8 @@ Name | Type | Description | Notes **discardedAt** | **Date** | The date and time the video was discarded. The API populates this field only if you have the Video Restore feature enabled and discard a video. Date and time are provided using ATOM UTC format. | [optional] **deletesAt** | **Date** | The date and time the video will be permanently deleted. The API populates this field only if you have the Video Restore feature enabled and discard a video. Discarded videos are pemanently deleted after 90 days. Date and time are provided using ATOM UTC format. | [optional] **discarded** | **boolean** | Returns `true` for videos you discarded when you have the Video Restore feature enabled. Returns `false` for every other video. | [optional] +**language** | **string** | Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. You can set the language during video creation via the API, otherwise it is detected automatically. | [optional] +**languageOrigin** | [**VideoLanguageOriginEnum**](#VideoLanguageOriginEnum) | Returns the origin of the last update on the video's `language` attribute. - `api` means that the last update was requested from the API. - `auto` means that the last update was done automatically by the API. | [optional] **tags** | **Array<string>** | One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. | [optional] **metadata** | [**Array<Metadata>**](Metadata.md) | Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. | [optional] **source** | [**VideoSource**](VideoSource.md) | | [optional] @@ -25,3 +27,12 @@ Name | Type | Description | Notes +## Enum: VideoLanguageOriginEnum + +Name | Value +---- | ----- +Api | 'api' +Auto | 'auto' + + + diff --git a/docs/model/VideoCreationPayload.md b/docs/model/VideoCreationPayload.md index 66a5253..9c6fc5b 100644 --- a/docs/model/VideoCreationPayload.md +++ b/docs/model/VideoCreationPayload.md @@ -16,6 +16,48 @@ Name | Type | Description | Notes **metadata** | [**Array<Metadata>**](Metadata.md) | A list of key value pairs that you use to provide metadata for your video. | [optional] **clip** | [**VideoClip**](VideoClip.md) | | [optional] **watermark** | [**VideoWatermark**](VideoWatermark.md) | | [optional] +**language** | [**VideoCreationPayloadLanguageEnum**](#VideoCreationPayloadLanguageEnum) | Use this parameter to set the language of the video. When this parameter is set, the API creates a transcript of the video using the language you specify. You must use the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. `language` is a permanent attribute of the video. You can update it to another language using the [`PATCH /videos/{videoId}`](https://docs.api.video/reference/api/Videos#update-a-video-object) operation. This triggers the API to generate a new transcript using a different language. | [optional] +**transcript** | **boolean** | Use this parameter to enable transcription. - When `true`, the API generates a transcript for the video. - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. | [optional] + + + +## Enum: VideoCreationPayloadLanguageEnum + +Name | Value +---- | ----- +Ar | 'ar' +Ca | 'ca' +Cs | 'cs' +Da | 'da' +De | 'de' +El | 'el' +En | 'en' +Es | 'es' +Fa | 'fa' +Fi | 'fi' +Fr | 'fr' +He | 'he' +Hi | 'hi' +Hr | 'hr' +Hu | 'hu' +It | 'it' +Ja | 'ja' +Ko | 'ko' +Ml | 'ml' +Nl | 'nl' +Nn | 'nn' +False | 'false' +Pl | 'pl' +Pt | 'pt' +Ru | 'ru' +Sk | 'sk' +Sl | 'sl' +Te | 'te' +Tr | 'tr' +Uk | 'uk' +Ur | 'ur' +Vi | 'vi' +Zh | 'zh' diff --git a/docs/model/VideoUpdatePayload.md b/docs/model/VideoUpdatePayload.md index ac0c9fe..4178d35 100644 --- a/docs/model/VideoUpdatePayload.md +++ b/docs/model/VideoUpdatePayload.md @@ -13,6 +13,48 @@ Name | Type | Description | Notes **mp4Support** | **boolean** | Whether the player supports the mp4 format. | [optional] **tags** | **Array<string>** | A list of terms or words you want to tag the video with. Make sure the list includes all the tags you want as whatever you send in this list will overwrite the existing list for the video. | [optional] **metadata** | [**Array<Metadata>**](Metadata.md) | A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. | [optional] +**language** | [**VideoUpdatePayloadLanguageEnum**](#VideoUpdatePayloadLanguageEnum) | Use this parameter to set the language of the video. When this parameter is set, the API creates a transcript of the video using the language you specify. You must use the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. `language` is a permanent attribute of the video. You can update it to another language using the [`PATCH /videos/{videoId}`](https://docs.api.video/reference/api/Videos#update-a-video-object) operation. This triggers the API to generate a new transcript using a different language. | [optional] +**transcript** | **boolean** | Use this parameter to enable transcription. - When `true`, the API generates a transcript for the video. - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. | [optional] + + + +## Enum: VideoUpdatePayloadLanguageEnum + +Name | Value +---- | ----- +Ar | 'ar' +Ca | 'ca' +Cs | 'cs' +Da | 'da' +De | 'de' +El | 'el' +En | 'en' +Es | 'es' +Fa | 'fa' +Fi | 'fi' +Fr | 'fr' +He | 'he' +Hi | 'hi' +Hr | 'hr' +Hu | 'hu' +It | 'it' +Ja | 'ja' +Ko | 'ko' +Ml | 'ml' +Nl | 'nl' +Nn | 'nn' +False | 'false' +Pl | 'pl' +Pt | 'pt' +Ru | 'ru' +Sk | 'sk' +Sl | 'sl' +Te | 'te' +Tr | 'tr' +Uk | 'uk' +Ur | 'ur' +Vi | 'vi' +Zh | 'zh' diff --git a/package.json b/package.json index ce3e0b8..e45b583 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@api.video/nodejs-client", - "version": "2.6.3", + "version": "2.6.4", "description": "api.video nodejs API client", "keywords": [ "api.video", diff --git a/src/HttpClient.ts b/src/HttpClient.ts index 994d992..d60ad71 100644 --- a/src/HttpClient.ts +++ b/src/HttpClient.ts @@ -59,7 +59,7 @@ export default class HttpClient { this.chunkSize = params.chunkSize; this.headers = new AxiosHeaders({ Accept: 'application/json, */*;q=0.8', - 'AV-Origin-Client': 'nodejs:2.6.3', + 'AV-Origin-Client': 'nodejs:2.6.4', Authorization: this.apiKey ? `Basic ${encode(`${this.apiKey}:`)}` : '', ...(params.applicationName && params.applicationVersion ? { diff --git a/src/ObjectSerializer.ts b/src/ObjectSerializer.ts index 1aade28..037fd7a 100644 --- a/src/ObjectSerializer.ts +++ b/src/ObjectSerializer.ts @@ -119,7 +119,10 @@ const enumsMap: Set = new Set([ 'QualityTypeEnum', 'QualityQualityEnum', 'QualityStatusEnum', + 'VideoLanguageOriginEnum', + 'VideoCreationPayloadLanguageEnum', 'VideoStatusIngestStatusEnum', + 'VideoUpdatePayloadLanguageEnum', ]); const typeMap: { [index: string]: any } = { diff --git a/src/model/Video.ts b/src/model/Video.ts index 3cad248..3b2317e 100644 --- a/src/model/Video.ts +++ b/src/model/Video.ts @@ -51,6 +51,14 @@ export default class Video { * Returns `true` for videos you discarded when you have the Video Restore feature enabled. Returns `false` for every other video. */ 'discarded'?: boolean; + /** + * Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. You can set the language during video creation via the API, otherwise it is detected automatically. + */ + 'language'?: string; + /** + * Returns the origin of the last update on the video's `language` attribute. - `api` means that the last update was requested from the API. - `auto` means that the last update was done automatically by the API. + */ + 'languageOrigin'?: VideoLanguageOriginEnum; /** * One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. */ @@ -135,6 +143,18 @@ export default class Video { type: 'boolean', format: '', }, + { + name: 'language', + baseName: 'language', + type: 'string', + format: '', + }, + { + name: 'languageOrigin', + baseName: 'languageOrigin', + type: 'VideoLanguageOriginEnum', + format: '', + }, { name: 'tags', baseName: 'tags', @@ -189,3 +209,5 @@ export default class Video { return Video.attributeTypeMap; } } + +export type VideoLanguageOriginEnum = 'api' | 'auto'; diff --git a/src/model/VideoCreationPayload.ts b/src/model/VideoCreationPayload.ts index c850560..2595e05 100644 --- a/src/model/VideoCreationPayload.ts +++ b/src/model/VideoCreationPayload.ts @@ -53,6 +53,14 @@ export default class VideoCreationPayload { 'metadata'?: Array; 'clip'?: VideoClip; 'watermark'?: VideoWatermark; + /** + * Use this parameter to set the language of the video. When this parameter is set, the API creates a transcript of the video using the language you specify. You must use the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. `language` is a permanent attribute of the video. You can update it to another language using the [`PATCH /videos/{videoId}`](https://docs.api.video/reference/api/Videos#update-a-video-object) operation. This triggers the API to generate a new transcript using a different language. + */ + 'language'?: VideoCreationPayloadLanguageEnum; + /** + * Use this parameter to enable transcription. - When `true`, the API generates a transcript for the video. - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. + */ + 'transcript'?: boolean; static readonly discriminator?: string = undefined; @@ -123,9 +131,56 @@ export default class VideoCreationPayload { type: 'VideoWatermark', format: '', }, + { + name: 'language', + baseName: 'language', + type: 'VideoCreationPayloadLanguageEnum', + format: '', + }, + { + name: 'transcript', + baseName: 'transcript', + type: 'boolean', + format: '', + }, ]; static getAttributeTypeMap(): Array { return VideoCreationPayload.attributeTypeMap; } } + +export type VideoCreationPayloadLanguageEnum = + | 'ar' + | 'ca' + | 'cs' + | 'da' + | 'de' + | 'el' + | 'en' + | 'es' + | 'fa' + | 'fi' + | 'fr' + | 'he' + | 'hi' + | 'hr' + | 'hu' + | 'it' + | 'ja' + | 'ko' + | 'ml' + | 'nl' + | 'nn' + | 'false' + | 'pl' + | 'pt' + | 'ru' + | 'sk' + | 'sl' + | 'te' + | 'tr' + | 'uk' + | 'ur' + | 'vi' + | 'zh'; diff --git a/src/model/VideoUpdatePayload.ts b/src/model/VideoUpdatePayload.ts index 6f176ae..5d7ab1e 100644 --- a/src/model/VideoUpdatePayload.ts +++ b/src/model/VideoUpdatePayload.ts @@ -45,6 +45,14 @@ export default class VideoUpdatePayload { * A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. */ 'metadata'?: Array; + /** + * Use this parameter to set the language of the video. When this parameter is set, the API creates a transcript of the video using the language you specify. You must use the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. `language` is a permanent attribute of the video. You can update it to another language using the [`PATCH /videos/{videoId}`](https://docs.api.video/reference/api/Videos#update-a-video-object) operation. This triggers the API to generate a new transcript using a different language. + */ + 'language'?: VideoUpdatePayloadLanguageEnum; + /** + * Use this parameter to enable transcription. - When `true`, the API generates a transcript for the video. - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. + */ + 'transcript'?: boolean; static readonly discriminator?: string = undefined; @@ -97,9 +105,56 @@ export default class VideoUpdatePayload { type: 'Array', format: '', }, + { + name: 'language', + baseName: 'language', + type: 'VideoUpdatePayloadLanguageEnum', + format: '', + }, + { + name: 'transcript', + baseName: 'transcript', + type: 'boolean', + format: '', + }, ]; static getAttributeTypeMap(): Array { return VideoUpdatePayload.attributeTypeMap; } } + +export type VideoUpdatePayloadLanguageEnum = + | 'ar' + | 'ca' + | 'cs' + | 'da' + | 'de' + | 'el' + | 'en' + | 'es' + | 'fa' + | 'fi' + | 'fr' + | 'he' + | 'hi' + | 'hr' + | 'hu' + | 'it' + | 'ja' + | 'ko' + | 'ml' + | 'nl' + | 'nn' + | 'false' + | 'pl' + | 'pt' + | 'ru' + | 'sk' + | 'sl' + | 'te' + | 'tr' + | 'uk' + | 'ur' + | 'vi' + | 'zh'; diff --git a/test/payloads/videos/create/responses201.json b/test/payloads/videos/create/responses201.json index fbcda04..6d0d225 100644 --- a/test/payloads/videos/create/responses201.json +++ b/test/payloads/videos/create/responses201.json @@ -2,6 +2,8 @@ "videoId" : "vi4blUQJFrYWbaG44NChkH27", "title" : "Maths video", "description" : "An amazing video explaining the string theory", + "language" : "en", + "languageOrigin" : "api", "public" : false, "panoramic" : false, "mp4Support" : true, diff --git a/test/payloads/videos/create/responses400.json b/test/payloads/videos/create/responses400-0.json similarity index 100% rename from test/payloads/videos/create/responses400.json rename to test/payloads/videos/create/responses400-0.json diff --git a/test/payloads/videos/create/responses400-1.json b/test/payloads/videos/create/responses400-1.json new file mode 100644 index 0000000..c67814e --- /dev/null +++ b/test/payloads/videos/create/responses400-1.json @@ -0,0 +1,7 @@ +{ + "type" : "https://docs.api.video/reference/invalid-attribute", + "title" : "An attribute is invalid.", + "status" : 400, + "detail" : "The \"language\" attribute must contain only letters and dashes (for example \"fr\", \"fr-BE\").", + "name" : "language" +} \ No newline at end of file diff --git a/test/payloads/videos/create/responses400-2.json b/test/payloads/videos/create/responses400-2.json new file mode 100644 index 0000000..fc103e0 --- /dev/null +++ b/test/payloads/videos/create/responses400-2.json @@ -0,0 +1,7 @@ +{ + "type" : "https://docs.api.video/reference/invalid-attribute", + "title" : "An attribute is invalid.", + "status" : 400, + "detail" : "The \"language\" attribute is not valid.", + "name" : "language" +} \ No newline at end of file diff --git a/test/payloads/videos/get/responses200.json b/test/payloads/videos/get/responses200.json index c6df209..05a4a7a 100644 --- a/test/payloads/videos/get/responses200.json +++ b/test/payloads/videos/get/responses200.json @@ -3,6 +3,8 @@ "playerId" : "pl45KFKdlddgk654dspkze", "title" : "Maths video", "description" : "An amazing video explaining string theory", + "language" : "en", + "languageOrigin" : "api", "public" : false, "panoramic" : false, "mp4Support" : true, diff --git a/test/payloads/videos/list/responses200.json b/test/payloads/videos/list/responses200.json index 16b27a5..e2747ed 100644 --- a/test/payloads/videos/list/responses200.json +++ b/test/payloads/videos/list/responses200.json @@ -4,6 +4,8 @@ "playerId" : "pl45KFKdlddgk654dspkze", "title" : "Maths video", "description" : "An amazing video explaining the string theory", + "language" : "en", + "languageOrigin" : "api", "public" : false, "panoramic" : false, "mp4Support" : true, @@ -32,6 +34,8 @@ "videoId" : "vi4blUQJFrYWbaG44NChkH27", "title" : "Video Title", "description" : "A description for your video.", + "language" : "en", + "languageOrigin" : "api", "public" : false, "panoramic" : false, "mp4Support" : true, @@ -64,6 +68,8 @@ "playerId" : "pl45KFKdlddgk654dspkze", "title" : "My Video Title", "description" : "A brief description of the video.", + "language" : "fr", + "languageOrigin" : "api", "public" : false, "panoramic" : false, "mp4Support" : true, diff --git a/test/payloads/videos/update/responses200.json b/test/payloads/videos/update/responses200.json index f466a51..db100f4 100644 --- a/test/payloads/videos/update/responses200.json +++ b/test/payloads/videos/update/responses200.json @@ -3,6 +3,8 @@ "playerId" : "pl45KFKdlddgk654dspkze", "title" : "Maths video", "description" : "An amazing video explaining the string theory", + "language" : "en", + "languageOrigin" : "api", "public" : false, "panoramic" : false, "mp4Support" : true, diff --git a/test/payloads/videos/update/responses400.json b/test/payloads/videos/update/responses400-0.json similarity index 100% rename from test/payloads/videos/update/responses400.json rename to test/payloads/videos/update/responses400-0.json diff --git a/test/payloads/videos/update/responses400-1.json b/test/payloads/videos/update/responses400-1.json new file mode 100644 index 0000000..c67814e --- /dev/null +++ b/test/payloads/videos/update/responses400-1.json @@ -0,0 +1,7 @@ +{ + "type" : "https://docs.api.video/reference/invalid-attribute", + "title" : "An attribute is invalid.", + "status" : 400, + "detail" : "The \"language\" attribute must contain only letters and dashes (for example \"fr\", \"fr-BE\").", + "name" : "language" +} \ No newline at end of file diff --git a/test/payloads/videos/update/responses400-2.json b/test/payloads/videos/update/responses400-2.json new file mode 100644 index 0000000..fc103e0 --- /dev/null +++ b/test/payloads/videos/update/responses400-2.json @@ -0,0 +1,7 @@ +{ + "type" : "https://docs.api.video/reference/invalid-attribute", + "title" : "An attribute is invalid.", + "status" : 400, + "detail" : "The \"language\" attribute is not valid.", + "name" : "language" +} \ No newline at end of file diff --git a/test/payloads/videos/uploadWithUploadToken/responses201.json b/test/payloads/videos/uploadWithUploadToken/responses201.json index 8aeb102..37424d1 100644 --- a/test/payloads/videos/uploadWithUploadToken/responses201.json +++ b/test/payloads/videos/uploadWithUploadToken/responses201.json @@ -3,6 +3,7 @@ "playerId" : "pl45KFKdlddgk654dspkze", "title" : "Maths video", "description" : "An amazing video explaining the string theory", + "language" : "en", "public" : false, "panoramic" : false, "tags" : [ "maths", "string theory", "video" ],