Skip to content

Commit 7adb44b

Browse files
Merge pull request #90 from apivideo/add-transcript-feature
Add transcript feature
2 parents e8ce368 + a52284c commit 7adb44b

File tree

24 files changed

+166
-12
lines changed

24 files changed

+166
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
49fece4f39cb92341dc77e0eb7371a152903bf6aebcfa250d289efc9018b0f72
1+
5ad86d4a6e6bdfede262551219ba43c8a645a86bc20fc9740b6f950e86f99f1d

ApiVideoClient.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Pod::Spec.new do |s|
55
s.tvos.deployment_target = '10.0'
66
# Add back when CocoaPods/CocoaPods#11558 is released
77
#s.watchos.deployment_target = '3.0'
8-
s.version = '1.3.3'
9-
s.source = { :git => 'https://github.com/apivideo/api.video-swift-client', :tag => 'v1.3.3' }
8+
s.version = '1.3.4'
9+
s.source = { :git => 'https://github.com/apivideo/api.video-swift-client', :tag => 'v1.3.4' }
1010
s.authors = { 'Ecosystem Team' => 'ecosystem@api.video' }
1111
s.license = { :type => 'MIT' }
1212
s.homepage = 'https://docs.api.video'

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.3.4] - 2024-10-08
5+
- Add transcript feature
6+
47
## [1.3.3] - 2024-09-30
58
- Add /tags API endpoint
69

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ api.video's Swift API client for iOS, macOS and tvOS streamlines the coding proc
5656
Specify it in your `Cartfile`:
5757

5858
```
59-
github "apivideo/api.video-swift-client" ~> 1.3.3
59+
github "apivideo/api.video-swift-client" ~> 1.3.4
6060
```
6161

6262
Run `carthage update`
6363

6464
#### CocoaPods
6565

66-
Add `pod 'ApiVideoClient', '1.3.3'` in your `Podfile`
66+
Add `pod 'ApiVideoClient', '1.3.4'` in your `Podfile`
6767

6868
Run `pod install`
6969

Sources/APIs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Foundation
88
public class ApiVideoClient {
99
public static var apiKey: String? = nil
1010
public static var basePath = "https://ws.api.video"
11-
internal static var customHeaders:[String: String] = ["AV-Origin-Client": "swift:1.3.3"]
11+
internal static var customHeaders:[String: String] = ["AV-Origin-Client": "swift:1.3.4"]
1212
private static var chunkSize: Int = 50 * 1024 * 1024
1313
internal static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
1414
internal static var credential = ApiVideoCredential()

Sources/Models/Video.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import AnyCodable
1212

1313
public struct Video: Codable, Hashable {
1414

15+
public enum LanguageOrigin: String, Codable, CaseIterable {
16+
case api = "api"
17+
case auto = "auto"
18+
}
1519
/** The unique identifier of the video object. */
1620
public var videoId: String
1721
/** When a video was created, presented in ATOM UTC format. */
@@ -30,6 +34,10 @@ public struct Video: Codable, Hashable {
3034
public var deletesAt: Date?
3135
/** Returns `true` for videos you discarded when you have the Video Restore feature enabled. Returns `false` for every other video. */
3236
public var discarded: Bool?
37+
/** 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. */
38+
public var language: String?
39+
/** 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. */
40+
public var languageOrigin: LanguageOrigin?
3341
/** One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. */
3442
public var tags: [String]?
3543
/** 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. */
@@ -45,7 +53,7 @@ public struct Video: Codable, Hashable {
4553
/** This lets you know whether mp4 is supported. If enabled, an mp4 URL will be provided in the response for the video. */
4654
public var mp4Support: Bool?
4755

48-
public init(videoId: String, createdAt: Date? = nil, title: String? = nil, description: String? = nil, publishedAt: Date? = nil, updatedAt: Date? = nil, discardedAt: Date? = nil, deletesAt: Date? = nil, discarded: Bool? = nil, tags: [String]? = nil, metadata: [Metadata]? = nil, source: VideoSource? = nil, assets: VideoAssets? = nil, playerId: String? = nil, _public: Bool? = nil, panoramic: Bool? = nil, mp4Support: Bool? = nil) {
56+
public init(videoId: String, createdAt: Date? = nil, title: String? = nil, description: String? = nil, publishedAt: Date? = nil, updatedAt: Date? = nil, discardedAt: Date? = nil, deletesAt: Date? = nil, discarded: Bool? = nil, language: String? = nil, languageOrigin: LanguageOrigin? = nil, tags: [String]? = nil, metadata: [Metadata]? = nil, source: VideoSource? = nil, assets: VideoAssets? = nil, playerId: String? = nil, _public: Bool? = nil, panoramic: Bool? = nil, mp4Support: Bool? = nil) {
4957
self.videoId = videoId
5058
self.createdAt = createdAt
5159
self.title = title
@@ -55,6 +63,8 @@ public struct Video: Codable, Hashable {
5563
self.discardedAt = discardedAt
5664
self.deletesAt = deletesAt
5765
self.discarded = discarded
66+
self.language = language
67+
self.languageOrigin = languageOrigin
5868
self.tags = tags
5969
self.metadata = metadata
6070
self.source = source
@@ -75,6 +85,8 @@ public struct Video: Codable, Hashable {
7585
case discardedAt
7686
case deletesAt
7787
case discarded
88+
case language
89+
case languageOrigin
7890
case tags
7991
case metadata
8092
case source
@@ -98,6 +110,8 @@ public struct Video: Codable, Hashable {
98110
try container.encodeIfPresent(discardedAt, forKey: .discardedAt)
99111
try container.encodeIfPresent(deletesAt, forKey: .deletesAt)
100112
try container.encodeIfPresent(discarded, forKey: .discarded)
113+
try container.encodeIfPresent(language, forKey: .language)
114+
try container.encodeIfPresent(languageOrigin, forKey: .languageOrigin)
101115
try container.encodeIfPresent(tags, forKey: .tags)
102116
try container.encodeIfPresent(metadata, forKey: .metadata)
103117
try container.encodeIfPresent(source, forKey: .source)

Sources/Models/VideoCreationPayload.swift

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,41 @@ import AnyCodable
1212

1313
public struct VideoCreationPayload: Codable, Hashable {
1414

15+
public enum Language: String, Codable, CaseIterable {
16+
case ar = "ar"
17+
case ca = "ca"
18+
case cs = "cs"
19+
case da = "da"
20+
case de = "de"
21+
case el = "el"
22+
case en = "en"
23+
case es = "es"
24+
case fa = "fa"
25+
case fi = "fi"
26+
case fr = "fr"
27+
case he = "he"
28+
case hi = "hi"
29+
case hr = "hr"
30+
case hu = "hu"
31+
case it = "it"
32+
case ja = "ja"
33+
case ko = "ko"
34+
case ml = "ml"
35+
case nl = "nl"
36+
case nn = "nn"
37+
case _false = "false"
38+
case pl = "pl"
39+
case pt = "pt"
40+
case ru = "ru"
41+
case sk = "sk"
42+
case sl = "sl"
43+
case te = "te"
44+
case tr = "tr"
45+
case uk = "uk"
46+
case ur = "ur"
47+
case vi = "vi"
48+
case zh = "zh"
49+
}
1550
/** The title of your new video. */
1651
public var title: String
1752
/** A brief description of your video. */
@@ -32,8 +67,12 @@ public struct VideoCreationPayload: Codable, Hashable {
3267
public var metadata: [Metadata]?
3368
public var clip: VideoClip?
3469
public var watermark: VideoWatermark?
70+
/** 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. */
71+
public var language: Language?
72+
/** 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. */
73+
public var transcript: Bool?
3574

36-
public init(title: String, description: String? = nil, source: String? = nil, _public: Bool? = true, panoramic: Bool? = false, mp4Support: Bool? = true, playerId: String? = nil, tags: [String]? = nil, metadata: [Metadata]? = nil, clip: VideoClip? = nil, watermark: VideoWatermark? = nil) {
75+
public init(title: String, description: String? = nil, source: String? = nil, _public: Bool? = true, panoramic: Bool? = false, mp4Support: Bool? = true, playerId: String? = nil, tags: [String]? = nil, metadata: [Metadata]? = nil, clip: VideoClip? = nil, watermark: VideoWatermark? = nil, language: Language? = nil, transcript: Bool? = nil) {
3776
self.title = title
3877
self.description = description
3978
self.source = source
@@ -45,6 +84,8 @@ public struct VideoCreationPayload: Codable, Hashable {
4584
self.metadata = metadata
4685
self.clip = clip
4786
self.watermark = watermark
87+
self.language = language
88+
self.transcript = transcript
4889
}
4990

5091
public enum CodingKeys: String, CodingKey, CaseIterable {
@@ -59,6 +100,8 @@ public struct VideoCreationPayload: Codable, Hashable {
59100
case metadata
60101
case clip
61102
case watermark
103+
case language
104+
case transcript
62105
}
63106

64107
// Encodable protocol methods
@@ -76,6 +119,8 @@ public struct VideoCreationPayload: Codable, Hashable {
76119
try container.encodeIfPresent(metadata, forKey: .metadata)
77120
try container.encodeIfPresent(clip, forKey: .clip)
78121
try container.encodeIfPresent(watermark, forKey: .watermark)
122+
try container.encodeIfPresent(language, forKey: .language)
123+
try container.encodeIfPresent(transcript, forKey: .transcript)
79124
}
80125
}
81126

Sources/Models/VideoUpdatePayload.swift

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,41 @@ import AnyCodable
1212

1313
public struct VideoUpdatePayload: Codable, Hashable {
1414

15+
public enum Language: String, Codable, CaseIterable {
16+
case ar = "ar"
17+
case ca = "ca"
18+
case cs = "cs"
19+
case da = "da"
20+
case de = "de"
21+
case el = "el"
22+
case en = "en"
23+
case es = "es"
24+
case fa = "fa"
25+
case fi = "fi"
26+
case fr = "fr"
27+
case he = "he"
28+
case hi = "hi"
29+
case hr = "hr"
30+
case hu = "hu"
31+
case it = "it"
32+
case ja = "ja"
33+
case ko = "ko"
34+
case ml = "ml"
35+
case nl = "nl"
36+
case nn = "nn"
37+
case _false = "false"
38+
case pl = "pl"
39+
case pt = "pt"
40+
case ru = "ru"
41+
case sk = "sk"
42+
case sl = "sl"
43+
case te = "te"
44+
case tr = "tr"
45+
case uk = "uk"
46+
case ur = "ur"
47+
case vi = "vi"
48+
case zh = "zh"
49+
}
1550
/** The unique ID for the player you want to associate with your video. */
1651
public var playerId: NullableString?
1752
/** The title you want to use for your video. */
@@ -28,8 +63,12 @@ public struct VideoUpdatePayload: Codable, Hashable {
2863
public var tags: [String]?
2964
/** 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. */
3065
public var metadata: [Metadata]?
66+
/** 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. */
67+
public var language: Language?
68+
/** 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. */
69+
public var transcript: Bool?
3170

32-
public init(playerId: NullableString? = nil, title: String? = nil, description: String? = nil, _public: Bool? = nil, panoramic: Bool? = nil, mp4Support: Bool? = nil, tags: [String]? = nil, metadata: [Metadata]? = nil) {
71+
public init(playerId: NullableString? = nil, title: String? = nil, description: String? = nil, _public: Bool? = nil, panoramic: Bool? = nil, mp4Support: Bool? = nil, tags: [String]? = nil, metadata: [Metadata]? = nil, language: Language? = nil, transcript: Bool? = nil) {
3372
self.playerId = playerId
3473
self.title = title
3574
self.description = description
@@ -38,6 +77,8 @@ public struct VideoUpdatePayload: Codable, Hashable {
3877
self.mp4Support = mp4Support
3978
self.tags = tags
4079
self.metadata = metadata
80+
self.language = language
81+
self.transcript = transcript
4182
}
4283

4384
public enum CodingKeys: String, CodingKey, CaseIterable {
@@ -49,6 +90,8 @@ public struct VideoUpdatePayload: Codable, Hashable {
4990
case mp4Support
5091
case tags
5192
case metadata
93+
case language
94+
case transcript
5295
}
5396

5497
// Encodable protocol methods
@@ -63,6 +106,8 @@ public struct VideoUpdatePayload: Codable, Hashable {
63106
try container.encodeIfPresent(mp4Support, forKey: .mp4Support)
64107
try container.encodeIfPresent(tags, forKey: .tags)
65108
try container.encodeIfPresent(metadata, forKey: .metadata)
109+
try container.encodeIfPresent(language, forKey: .language)
110+
try container.encodeIfPresent(transcript, forKey: .transcript)
66111
}
67112
}
68113

Tests/TestResources/payloads/videos/create/responses/201.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"videoId" : "vi4blUQJFrYWbaG44NChkH27",
33
"title" : "Maths video",
44
"description" : "An amazing video explaining the string theory",
5+
"language" : "en",
6+
"languageOrigin" : "api",
57
"public" : false,
68
"panoramic" : false,
79
"mp4Support" : true,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type" : "https://docs.api.video/reference/invalid-attribute",
3+
"title" : "An attribute is invalid.",
4+
"status" : 400,
5+
"detail" : "The \"language\" attribute must contain only letters and dashes (for example \"fr\", \"fr-BE\").",
6+
"name" : "language"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type" : "https://docs.api.video/reference/invalid-attribute",
3+
"title" : "An attribute is invalid.",
4+
"status" : 400,
5+
"detail" : "The \"language\" attribute is not valid.",
6+
"name" : "language"
7+
}

Tests/TestResources/payloads/videos/get/responses/200.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"playerId" : "pl45KFKdlddgk654dspkze",
44
"title" : "Maths video",
55
"description" : "An amazing video explaining string theory",
6+
"language" : "en",
7+
"languageOrigin" : "api",
68
"public" : false,
79
"panoramic" : false,
810
"mp4Support" : true,

Tests/TestResources/payloads/videos/list/responses/200.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"playerId" : "pl45KFKdlddgk654dspkze",
55
"title" : "Maths video",
66
"description" : "An amazing video explaining the string theory",
7+
"language" : "en",
8+
"languageOrigin" : "api",
79
"public" : false,
810
"panoramic" : false,
911
"mp4Support" : true,
@@ -32,6 +34,8 @@
3234
"videoId" : "vi4blUQJFrYWbaG44NChkH27",
3335
"title" : "Video Title",
3436
"description" : "A description for your video.",
37+
"language" : "en",
38+
"languageOrigin" : "api",
3539
"public" : false,
3640
"panoramic" : false,
3741
"mp4Support" : true,
@@ -64,6 +68,8 @@
6468
"playerId" : "pl45KFKdlddgk654dspkze",
6569
"title" : "My Video Title",
6670
"description" : "A brief description of the video.",
71+
"language" : "fr",
72+
"languageOrigin" : "api",
6773
"public" : false,
6874
"panoramic" : false,
6975
"mp4Support" : true,

Tests/TestResources/payloads/videos/update/responses/200.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"playerId" : "pl45KFKdlddgk654dspkze",
44
"title" : "Maths video",
55
"description" : "An amazing video explaining the string theory",
6+
"language" : "en",
7+
"languageOrigin" : "api",
68
"public" : false,
79
"panoramic" : false,
810
"mp4Support" : true,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type" : "https://docs.api.video/reference/invalid-attribute",
3+
"title" : "An attribute is invalid.",
4+
"status" : 400,
5+
"detail" : "The \"language\" attribute must contain only letters and dashes (for example \"fr\", \"fr-BE\").",
6+
"name" : "language"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type" : "https://docs.api.video/reference/invalid-attribute",
3+
"title" : "An attribute is invalid.",
4+
"status" : 400,
5+
"detail" : "The \"language\" attribute is not valid.",
6+
"name" : "language"
7+
}

Tests/TestResources/payloads/videos/uploadWithUploadToken/responses/201.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"playerId" : "pl45KFKdlddgk654dspkze",
44
"title" : "Maths video",
55
"description" : "An amazing video explaining the string theory",
6+
"language" : "en",
67
"public" : false,
78
"panoramic" : false,
89
"tags" : [ "maths", "string theory", "video" ],

docs/Video.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Name | Type | Description | Notes
1212
**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]
1313
**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]
1414
**discarded** | **Bool** | Returns `true` for videos you discarded when you have the Video Restore feature enabled. Returns `false` for every other video. | [optional]
15+
**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]
16+
**languageOrigin** | **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. | [optional]
1517
**tags** | **[String]** | One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. | [optional]
1618
**metadata** | [Metadata] | 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]
1719
**source** | [**VideoSource**](VideoSource.md) | | [optional]

docs/VideoCreationPayload.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Name | Type | Description | Notes
1414
**metadata** | [Metadata] | A list of key value pairs that you use to provide metadata for your video. | [optional]
1515
**clip** | [**VideoClip**](VideoClip.md) | | [optional]
1616
**watermark** | [**VideoWatermark**](VideoWatermark.md) | | [optional]
17+
**language** | **String** | 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]
18+
**transcript** | **Bool** | 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]
1719

1820
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1921

0 commit comments

Comments
 (0)