polyv-live-cli
Version:
CLI tool for managing PolyV live streaming services.
219 lines • 11.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecordServiceSdk = void 0;
const sdk_1 = require("../sdk");
class RecordServiceSdk {
constructor(authConfig, serviceConfig) {
this.authConfig = authConfig;
this.config = serviceConfig;
}
async getPlaybackSetting(channelId) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
const result = await client.channel.getPlaybackSetting(channelId);
const displayItem = {
channelId: String(result['channelId'] ?? channelId),
};
if (result['playbackEnabled'] !== undefined)
displayItem.playbackEnabled = result['playbackEnabled'];
if (result['type'] !== undefined)
displayItem.type = result['type'];
if (result['origin'] !== undefined)
displayItem.origin = result['origin'];
if (result['videoId'] !== undefined)
displayItem.videoId = result['videoId'];
if (result['videoName'] !== undefined)
displayItem.videoName = result['videoName'];
if (result['sectionEnabled'] !== undefined)
displayItem.sectionEnabled = result['sectionEnabled'];
if (result['globalSettingEnabled'] !== undefined)
displayItem.globalSettingEnabled = result['globalSettingEnabled'];
if (result['playbackMultiplierEnabled'] !== undefined)
displayItem.playbackMultiplierEnabled = result['playbackMultiplierEnabled'];
if (result['playbackProgressBarEnabled'] !== undefined)
displayItem.playbackProgressBarEnabled = result['playbackProgressBarEnabled'];
if (result['playbackProgressBarOperationType'] !== undefined)
displayItem.playbackProgressBarOperationType = result['playbackProgressBarOperationType'];
if (result['showPlayButtonEnabled'] !== undefined)
displayItem.showPlayButtonEnabled = result['showPlayButtonEnabled'];
if (result['chatPlaybackEnabled'] !== undefined)
displayItem.chatPlaybackEnabled = result['chatPlaybackEnabled'];
if (result['productPlaybackEnabled'] !== undefined)
displayItem.productPlaybackEnabled = result['productPlaybackEnabled'];
if (result['questionnairePlaybackEnabled'] !== undefined)
displayItem.questionnairePlaybackEnabled = result['questionnairePlaybackEnabled'];
if (result['qaPlaybackEnabled'] !== undefined)
displayItem.qaPlaybackEnabled = result['qaPlaybackEnabled'];
if (result['cardPushPlaybackEnabled'] !== undefined)
displayItem.cardPushPlaybackEnabled = result['cardPushPlaybackEnabled'];
if (result['checkInPlaybackEnabled'] !== undefined)
displayItem.checkInPlaybackEnabled = result['checkInPlaybackEnabled'];
if (result['crontabType'] !== undefined)
displayItem.crontabType = result['crontabType'];
if (result['startTime'] !== undefined)
displayItem.startTime = result['startTime'];
if (result['endTime'] !== undefined)
displayItem.endTime = result['endTime'];
return displayItem;
}
async setPlaybackSetting(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
const params = {};
if (options['playbackEnabled'] !== undefined)
params['playbackEnabled'] = options['playbackEnabled'];
if (options['type'] !== undefined)
params['type'] = options['type'];
if (options['origin'] !== undefined)
params['origin'] = options['origin'];
if (options['videoId'] !== undefined)
params['videoId'] = options['videoId'];
if (options['globalSettingEnabled'] !== undefined)
params['globalSettingEnabled'] = options['globalSettingEnabled'];
if (options['sectionEnabled'] !== undefined)
params['sectionEnabled'] = options['sectionEnabled'];
if (options['playbackMultiplierEnabled'] !== undefined)
params['playbackMultiplierEnabled'] = options['playbackMultiplierEnabled'];
if (options['playbackProgressBarEnabled'] !== undefined)
params['playbackProgressBarEnabled'] = options['playbackProgressBarEnabled'];
if (options['playbackProgressBarOperationType'] !== undefined)
params['playbackProgressBarOperationType'] = options['playbackProgressBarOperationType'];
if (options['showPlayButtonEnabled'] !== undefined)
params['showPlayButtonEnabled'] = options['showPlayButtonEnabled'];
if (options['chatPlaybackEnabled'] !== undefined)
params['chatPlaybackEnabled'] = options['chatPlaybackEnabled'];
if (options['productPlaybackEnabled'] !== undefined)
params['productPlaybackEnabled'] = options['productPlaybackEnabled'];
if (options['questionnairePlaybackEnabled'] !== undefined)
params['questionnairePlaybackEnabled'] = options['questionnairePlaybackEnabled'];
if (options['qaPlaybackEnabled'] !== undefined)
params['qaPlaybackEnabled'] = options['qaPlaybackEnabled'];
if (options['cardPushPlaybackEnabled'] !== undefined)
params['cardPushPlaybackEnabled'] = options['cardPushPlaybackEnabled'];
if (options['checkInPlaybackEnabled'] !== undefined)
params['checkInPlaybackEnabled'] = options['checkInPlaybackEnabled'];
const result = await client.channel.setPlaybackSetting(channelId, params);
return result;
}
async recordConvert(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
const userId = options.userId ?? this.authConfig.userId;
if (!userId) {
throw new Error('record convert (sync) 需要 userId:请通过 --user-id 传入,或确认当前账号已配置 userId');
}
if (!options.fileName || options.fileName.trim() === '') {
throw new Error('record convert (sync) 需要 --file-name');
}
const params = {
userId,
fileName: options.fileName,
};
if (options.sessionId)
params.sessionId = options.sessionId;
if (options.fileUrl)
params.fileUrl = options.fileUrl;
if (options.cataId !== undefined)
params.cataid = options.cataId;
if (options.cataName !== undefined)
params.cataname = options.cataName;
if (options.toPlayList !== undefined)
params.toPlayList = options.toPlayList;
if (options.setAsDefault !== undefined)
params.setAsDefault = options.setAsDefault;
const result = await client.channel.recordConvert(channelId, params);
return {
async: false,
vid: result.vid,
};
}
async recordConvertAsync(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
if (!options.fileIds || options.fileIds.trim() === '') {
throw new Error('record convert --async 需要 --file-ids(逗号分隔)。请先用 ' +
'`record file list -c <channelId> --user-id <userId> --session-ids <id>` 获取 fileId');
}
const params = {
fileIds: options.fileIds,
};
if (options.fileName !== undefined) {
params.fileName = options.fileName;
}
if (options.cataId !== undefined) {
params.cataId = options.cataId;
}
if (options.callbackUrl !== undefined) {
params.callbackUrl = options.callbackUrl;
}
await client.channel.recordConvertAsync(channelId, params);
return {
async: true,
};
}
async setRecordDefault(channelId, videoId, listType) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
await client.channel.setDefaultPlaybackVideo({
channelId,
videoId,
...(listType ? { listType } : {}),
});
return true;
}
async getRecordFile(channelId, fileId) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.getRecordFile(channelId, fileId);
}
async listRecordFiles(params) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
const userId = params.userId && params.userId.trim() !== ''
? params.userId
: this.authConfig.userId;
if (!userId) {
throw new Error('record file list 需要 userId:请通过 --user-id 传入,或确认当前账号已配置 userId');
}
return client.channel.listRecordFiles({ ...params, userId });
}
async listMaterialRecordFiles(params) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.v4Channel.listMaterialRecordFiles(params);
}
async clipRecordFile(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.clipRecordFile(channelId, options);
}
async mergeRecordFiles(params) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.mergeRecordFiles(params);
}
async recordMergeMp4(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.recordMergeMp4(channelId, options);
}
async recordMergeMp4Start(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.recordMergeMp4Start(channelId, options);
}
async deleteRecordFile(params) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
await client.channel.deleteRecordFile(params);
}
async convertRecordFileToVod(params) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.convertRecordFileToVod(params);
}
async recordAddBreakpoint(channelId, options) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.channel.recordAddBreakpoint(channelId, options);
}
async createRecordFileOutline(params) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.v4Channel.createRecordFileOutline(params);
}
async getRecordFileOutline(channelId, fileId) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
return client.v4Channel.getRecordFileOutline({ channelId, fileId });
}
async batchPublishRecordFileSubtitles(subtitles) {
const client = (0, sdk_1.createSdkClient)(this.authConfig, this.config.baseUrl);
await client.v4Channel.batchPublishRecordFileSubtitles({ subtitles });
}
}
exports.RecordServiceSdk = RecordServiceSdk;
//# sourceMappingURL=record.service.sdk.js.map