2022-03-22 10:58:49 -05:00
|
|
|
import { HttpStatusCode, VideoStudioTask } from '@shared/models'
|
2022-02-11 03:51:33 -06:00
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
|
|
|
|
2022-03-22 10:58:49 -05:00
|
|
|
export class VideoStudioCommand extends AbstractCommand {
|
2022-02-11 03:51:33 -06:00
|
|
|
|
2022-03-22 10:58:49 -05:00
|
|
|
static getComplexTask (): VideoStudioTask[] {
|
2022-02-11 03:51:33 -06:00
|
|
|
return [
|
|
|
|
// Total duration: 2
|
|
|
|
{
|
|
|
|
name: 'cut',
|
|
|
|
options: {
|
|
|
|
start: 1,
|
|
|
|
end: 3
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Total duration: 7
|
|
|
|
{
|
|
|
|
name: 'add-outro',
|
|
|
|
options: {
|
|
|
|
file: 'video_short.webm'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
name: 'add-watermark',
|
|
|
|
options: {
|
2023-06-06 04:14:13 -05:00
|
|
|
file: 'custom-thumbnail.png'
|
2022-02-11 03:51:33 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Total duration: 9
|
|
|
|
{
|
|
|
|
name: 'add-intro',
|
|
|
|
options: {
|
|
|
|
file: 'video_very_short_240p.mp4'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
createEditionTasks (options: OverrideCommandOptions & {
|
|
|
|
videoId: number | string
|
2022-03-22 10:58:49 -05:00
|
|
|
tasks: VideoStudioTask[]
|
2022-02-11 03:51:33 -06:00
|
|
|
}) {
|
2022-03-22 10:58:49 -05:00
|
|
|
const path = '/api/v1/videos/' + options.videoId + '/studio/edit'
|
2022-02-11 03:51:33 -06:00
|
|
|
const attaches: { [id: string]: any } = {}
|
|
|
|
|
|
|
|
for (let i = 0; i < options.tasks.length; i++) {
|
|
|
|
const task = options.tasks[i]
|
|
|
|
|
|
|
|
if (task.name === 'add-intro' || task.name === 'add-outro' || task.name === 'add-watermark') {
|
|
|
|
attaches[`tasks[${i}][options][file]`] = task.options.file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.postUploadRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
attaches,
|
|
|
|
fields: { tasks: options.tasks },
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|