import got, { Response as GotResponse } from 'got'
import { omit } from 'lodash'
import validator from 'validator'
-import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils'
+import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils'
+import { buildUUID } from '@shared/extra-utils'
import {
HttpStatusCode,
ResultList,
import { unwrapBody } from '../requests'
import { waitJobs } from '../server'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
+import { VideoSource } from '@shared/models/videos/video-source'
export type VideoEdit = Partial<Omit<VideoCreate, 'thumbnailfile' | 'previewfile'>> & {
fixture?: string
// ---------------------------------------------------------------------------
- view (options: OverrideCommandOptions & {
- id: number | string
- xForwardedFor?: string
- }) {
- const { id, xForwardedFor } = options
- const path = '/api/v1/videos/' + id + '/views'
-
- return this.postBodyRequest({
- ...options,
-
- path,
- xForwardedFor,
- implicitToken: false,
- defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
- })
- }
-
rate (options: OverrideCommandOptions & {
id: number | string
rating: UserVideoRateType
})
}
+ getSource (options: OverrideCommandOptions & {
+ id: number | string
+ }) {
+ const path = '/api/v1/videos/' + options.id + '/source'
+
+ return this.getRequestBody<VideoSource>({
+ ...options,
+
+ path,
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+
async getId (options: OverrideCommandOptions & {
uuid: number | string
}) {
size: number
contentLength?: number
contentRangeBuilder?: (start: number, chunk: any) => string
+ digestBuilder?: (chunk: any) => string
}) {
- const { pathUploadId, videoFilePath, size, contentLength, contentRangeBuilder, expectedStatus = HttpStatusCode.OK_200 } = options
+ const {
+ pathUploadId,
+ videoFilePath,
+ size,
+ contentLength,
+ contentRangeBuilder,
+ digestBuilder,
+ expectedStatus = HttpStatusCode.OK_200
+ } = options
const path = '/api/v1/videos/upload-resumable'
let start = 0
'Content-Length': contentLength ? contentLength + '' : chunk.length + ''
}
+ if (digestBuilder) {
+ Object.assign(headers, { digest: digestBuilder(chunk) })
+ }
+
const res = await got<{ video: VideoCreateResult }>({
url,
method: 'put',