-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(FEC-8766): add closed captions from multi request to external
- Loading branch information
1 parent
37aa74a
commit c10a5c9
Showing
13 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @flow | ||
declare type CaptionType = { [type: string]: string }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// @flow | ||
declare type ProviderEnvConfigObject = { | ||
serviceUrl: string, | ||
cdnUrl?: string | ||
cdnUrl?: string, | ||
experimentalLoadApiCaptions?: boolean | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @flow | ||
declare type PKExternalCaptionObject = { | ||
url: string, | ||
label: string, | ||
language: string, | ||
default: ?boolean, | ||
type: ?string | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// @flow | ||
import OVPConfiguration from './config'; | ||
|
||
const KalturaCaptionType: CaptionType = { | ||
SRT: '1', | ||
DFXP: '2', | ||
WEBVTT: '3', | ||
CAP: '4' | ||
}; | ||
|
||
const CaptionsFormats: {[format: string]: string} = { | ||
WEBVTT: 'vtt' | ||
}; | ||
|
||
const BASE_URL: string = 'index.php/service/caption_captionasset/action/serveWebVTT/captionAssetId/ASSET_ID/segmentIndex/-1/version/2/captions.vtt'; | ||
|
||
const ASSET_ID_INDEX: number = 6; | ||
const VERSION_INDEX: number = 10; | ||
|
||
class ExternalCaptionsBuilder { | ||
static createConfig(metadata: Object, ks: string): Array<PKExternalCaptionObject> { | ||
return metadata.filter(meta => [KalturaCaptionType.WEBVTT, KalturaCaptionType.SRT].includes(meta.format)).map(meta => { | ||
return { | ||
type: CaptionsFormats.WEBVTT, | ||
language: meta.language, | ||
label: meta.label, | ||
url: ExternalCaptionsBuilder.createUrl(meta, ks) | ||
}; | ||
}); | ||
} | ||
|
||
static createUrl(metadata: Object, ks: string): string { | ||
const config = OVPConfiguration.get(); | ||
let path = BASE_URL.split('/'); | ||
path[ASSET_ID_INDEX] = metadata.id; | ||
path[VERSION_INDEX] = metadata.version; | ||
path = path.join('/'); | ||
ks = ks ? `/ks/${ks}` : ``; | ||
return `${config.serviceUrl}/${path}${ks}`; | ||
} | ||
} | ||
|
||
export {ExternalCaptionsBuilder}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//@flow | ||
import ServiceResult from '../../common/base-service-result'; | ||
|
||
export default class KalturaCaptionAssetListResponse extends ServiceResult { | ||
totalCount: number; | ||
captions: Array<PKExternalCaptionObject>; | ||
|
||
/** | ||
* @constructor | ||
* @param {Object} metaDataResponse The response | ||
* @param {Object} urlObject response of the url | ||
*/ | ||
constructor(metaDataResponse: Object) { | ||
super(metaDataResponse); | ||
if (!this.hasError) { | ||
this.totalCount = metaDataResponse.totalCount; | ||
this.data = metaDataResponse.objects; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@flow | ||
import OVPService from './ovp-service'; | ||
import RequestBuilder from '../../../util/request-builder'; | ||
|
||
const SERVICE_NAME: string = 'caption_captionasset'; | ||
|
||
export default class OVPCaptionService extends OVPService { | ||
/** | ||
* Creates an instance of RequestBuilder for caption_captionasset.list | ||
* @function post | ||
* @param {string} serviceUrl The service base URL | ||
* @param {string} ks The ks | ||
* @param {string} entryId The uiConf ID | ||
* @returns {RequestBuilder} The request builder | ||
* @static | ||
*/ | ||
static list(serviceUrl: string, ks: string, entryId: string): RequestBuilder { | ||
const headers: Map<string, string> = new Map(); | ||
headers.set('Content-Type', 'application/json'); | ||
const request = new RequestBuilder(headers); | ||
request.service = SERVICE_NAME; | ||
request.action = 'list'; | ||
request.method = 'POST'; | ||
request.url = request.getUrl(serviceUrl); | ||
request.params = {ks: ks, 'filter:entryIdEqual': entryId}; | ||
return request; | ||
} | ||
} |