X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fserver-commands%2Fvideos%2Fvideos-command.ts;h=e952c9777d0187f502864cd1ace1dfc249578c23;hb=e722fb5923ddf11d72e48cec9788abc64327c22f;hp=21753ddc46a71beedf36856a32ab96f9aa0e4371;hpb=c3edc5b074aa4bb1861ed0a94d3713808e87170f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts index 21753ddc4..e952c9777 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/shared/server-commands/videos/videos-command.ts @@ -23,6 +23,7 @@ import { 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> & { fixture?: string @@ -107,23 +108,6 @@ export class VideosCommand extends AbstractCommand { // --------------------------------------------------------------------------- - 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 @@ -167,6 +151,20 @@ export class VideosCommand extends AbstractCommand { }) } + getSource (options: OverrideCommandOptions & { + id: number | string + }) { + const path = '/api/v1/videos/' + options.id + '/source' + + return this.getRequestBody({ + ...options, + + path, + implicitToken: true, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + } + async getId (options: OverrideCommandOptions & { uuid: number | string }) { @@ -499,8 +497,17 @@ export class VideosCommand extends AbstractCommand { 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 @@ -522,6 +529,10 @@ export class VideosCommand extends AbstractCommand { 'Content-Length': contentLength ? contentLength + '' : chunk.length + '' } + if (digestBuilder) { + Object.assign(headers, { digest: digestBuilder(chunk) }) + } + const res = await got<{ video: VideoCreateResult }>({ url, method: 'put',