aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r--shared/extra-utils/videos/blacklist-command.ts2
-rw-r--r--shared/extra-utils/videos/captions-command.ts2
-rw-r--r--shared/extra-utils/videos/captions.ts2
-rw-r--r--shared/extra-utils/videos/change-ownership-command.ts2
-rw-r--r--shared/extra-utils/videos/channels-command.ts2
-rw-r--r--shared/extra-utils/videos/comments-command.ts2
-rw-r--r--shared/extra-utils/videos/history-command.ts2
-rw-r--r--shared/extra-utils/videos/imports-command.ts2
-rw-r--r--shared/extra-utils/videos/live-command.ts2
-rw-r--r--shared/extra-utils/videos/playlists-command.ts2
-rw-r--r--shared/extra-utils/videos/services-command.ts2
-rw-r--r--shared/extra-utils/videos/streaming-playlists-command.ts3
-rw-r--r--shared/extra-utils/videos/streaming-playlists.ts2
-rw-r--r--shared/extra-utils/videos/videos-command.ts36
-rw-r--r--shared/extra-utils/videos/videos.ts2
15 files changed, 34 insertions, 31 deletions
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts
index fdae6b469..9404d4c08 100644
--- a/shared/extra-utils/videos/blacklist-command.ts
+++ b/shared/extra-utils/videos/blacklist-command.ts
@@ -1,6 +1,6 @@
1 1
2import { ResultList } from '@shared/models' 2import { ResultList } from '@shared/models'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '@shared/models'
4import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' 4import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'
5import { AbstractCommand, OverrideCommandOptions } from '../shared' 5import { AbstractCommand, OverrideCommandOptions } from '../shared'
6 6
diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts
index ac3bde7a9..04dd32f84 100644
--- a/shared/extra-utils/videos/captions-command.ts
+++ b/shared/extra-utils/videos/captions-command.ts
@@ -1,4 +1,4 @@
1import { HttpStatusCode } from '@shared/core-utils' 1import { HttpStatusCode } from '@shared/models'
2import { ResultList, VideoCaption } from '@shared/models' 2import { ResultList, VideoCaption } from '@shared/models'
3import { buildAbsoluteFixturePath } from '../miscs' 3import { buildAbsoluteFixturePath } from '../miscs'
4import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/captions.ts b/shared/extra-utils/videos/captions.ts
index 2246bd133..ff8a43366 100644
--- a/shared/extra-utils/videos/captions.ts
+++ b/shared/extra-utils/videos/captions.ts
@@ -1,6 +1,6 @@
1import { expect } from 'chai' 1import { expect } from 'chai'
2import * as request from 'supertest' 2import * as request from 'supertest'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '@shared/models'
4 4
5async function testCaptionFile (url: string, captionPath: string, containsString: string) { 5async function testCaptionFile (url: string, captionPath: string, containsString: string) {
6 const res = await request(url) 6 const res = await request(url)
diff --git a/shared/extra-utils/videos/change-ownership-command.ts b/shared/extra-utils/videos/change-ownership-command.ts
index 03f77a95f..ef6f07536 100644
--- a/shared/extra-utils/videos/change-ownership-command.ts
+++ b/shared/extra-utils/videos/change-ownership-command.ts
@@ -1,6 +1,6 @@
1 1
2import { ResultList, VideoChangeOwnership } from '@shared/models' 2import { ResultList, VideoChangeOwnership } from '@shared/models'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '@shared/models'
4import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 5
6export class ChangeOwnershipCommand extends AbstractCommand { 6export class ChangeOwnershipCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts
index a98c5cc93..e5393ff56 100644
--- a/shared/extra-utils/videos/channels-command.ts
+++ b/shared/extra-utils/videos/channels-command.ts
@@ -1,6 +1,6 @@
1import { pick } from 'lodash' 1import { pick } from 'lodash'
2import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' 2import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '@shared/models'
4import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' 4import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'
5import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' 5import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'
6import { unwrapBody } from '../requests' 6import { unwrapBody } from '../requests'
diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts
index b31f3e2dd..7368f3ea2 100644
--- a/shared/extra-utils/videos/comments-command.ts
+++ b/shared/extra-utils/videos/comments-command.ts
@@ -1,6 +1,6 @@
1import { pick } from 'lodash' 1import { pick } from 'lodash'
2import { HttpStatusCode } from '@shared/models'
2import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' 3import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
4import { unwrapBody } from '../requests' 4import { unwrapBody } from '../requests'
5import { AbstractCommand, OverrideCommandOptions } from '../shared' 5import { AbstractCommand, OverrideCommandOptions } from '../shared'
6 6
diff --git a/shared/extra-utils/videos/history-command.ts b/shared/extra-utils/videos/history-command.ts
index 8a144a312..41afc6bc6 100644
--- a/shared/extra-utils/videos/history-command.ts
+++ b/shared/extra-utils/videos/history-command.ts
@@ -1,5 +1,5 @@
1import { HttpStatusCode } from '@shared/models'
1import { ResultList, Video } from '@shared/models' 2import { ResultList, Video } from '@shared/models'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { AbstractCommand, OverrideCommandOptions } from '../shared' 3import { AbstractCommand, OverrideCommandOptions } from '../shared'
4 4
5export class HistoryCommand extends AbstractCommand { 5export class HistoryCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts
index de8b65829..d30f9745b 100644
--- a/shared/extra-utils/videos/imports-command.ts
+++ b/shared/extra-utils/videos/imports-command.ts
@@ -1,6 +1,6 @@
1 1
2import { HttpStatusCode } from '@shared/models'
2import { ResultList } from '@shared/models' 3import { ResultList } from '@shared/models'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
4import { VideoImport, VideoImportCreate } from '../../models/videos' 4import { VideoImport, VideoImportCreate } from '../../models/videos'
5import { unwrapBody } from '../requests' 5import { unwrapBody } from '../requests'
6import { AbstractCommand, OverrideCommandOptions } from '../shared' 6import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts
index fd66c9924..9dfe3087e 100644
--- a/shared/extra-utils/videos/live-command.ts
+++ b/shared/extra-utils/videos/live-command.ts
@@ -3,8 +3,8 @@
3import { readdir } from 'fs-extra' 3import { readdir } from 'fs-extra'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { join } from 'path' 5import { join } from 'path'
6import { HttpStatusCode } from '@shared/models'
6import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' 7import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
7import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
8import { wait } from '../miscs' 8import { wait } from '../miscs'
9import { unwrapBody } from '../requests' 9import { unwrapBody } from '../requests'
10import { AbstractCommand, OverrideCommandOptions } from '../shared' 10import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts
index cbfc7e10f..40162c30d 100644
--- a/shared/extra-utils/videos/playlists-command.ts
+++ b/shared/extra-utils/videos/playlists-command.ts
@@ -1,5 +1,5 @@
1import { omit, pick } from 'lodash' 1import { omit, pick } from 'lodash'
2import { HttpStatusCode } from '@shared/core-utils' 2import { HttpStatusCode } from '@shared/models'
3import { 3import {
4 BooleanBothQuery, 4 BooleanBothQuery,
5 ResultList, 5 ResultList,
diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts
index 313b7878c..06760df42 100644
--- a/shared/extra-utils/videos/services-command.ts
+++ b/shared/extra-utils/videos/services-command.ts
@@ -1,4 +1,4 @@
1import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 1import { HttpStatusCode } from '@shared/models'
2import { AbstractCommand, OverrideCommandOptions } from '../shared' 2import { AbstractCommand, OverrideCommandOptions } from '../shared'
3 3
4export class ServicesCommand extends AbstractCommand { 4export class ServicesCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/streaming-playlists-command.ts b/shared/extra-utils/videos/streaming-playlists-command.ts
index fab3eb556..9662685da 100644
--- a/shared/extra-utils/videos/streaming-playlists-command.ts
+++ b/shared/extra-utils/videos/streaming-playlists-command.ts
@@ -1,5 +1,4 @@
1 1import { HttpStatusCode } from '@shared/models'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { unwrapBody, unwrapText } from '../requests' 2import { unwrapBody, unwrapText } from '../requests'
4import { AbstractCommand, OverrideCommandOptions } from '../shared' 3import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 4
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts
index 002ae08b2..007d3d98d 100644
--- a/shared/extra-utils/videos/streaming-playlists.ts
+++ b/shared/extra-utils/videos/streaming-playlists.ts
@@ -1,6 +1,6 @@
1import { expect } from 'chai' 1import { expect } from 'chai'
2import { sha256 } from '@server/helpers/core-utils' 2import { sha256 } from '@server/helpers/core-utils'
3import { HttpStatusCode } from '@shared/core-utils' 3import { HttpStatusCode } from '@shared/models'
4import { VideoStreamingPlaylist } from '@shared/models' 4import { VideoStreamingPlaylist } from '@shared/models'
5import { PeerTubeServer } from '../server' 5import { PeerTubeServer } from '../server'
6 6
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts
index feef5a771..f46d386f4 100644
--- a/shared/extra-utils/videos/videos-command.ts
+++ b/shared/extra-utils/videos/videos-command.ts
@@ -7,7 +7,7 @@ import { omit, pick } from 'lodash'
7import validator from 'validator' 7import validator from 'validator'
8import { buildUUID } from '@server/helpers/uuid' 8import { buildUUID } from '@server/helpers/uuid'
9import { loadLanguages } from '@server/initializers/constants' 9import { loadLanguages } from '@server/initializers/constants'
10import { HttpStatusCode } from '@shared/core-utils' 10import { HttpStatusCode } from '@shared/models'
11import { 11import {
12 ResultList, 12 ResultList,
13 UserVideoRateType, 13 UserVideoRateType,
@@ -234,10 +234,10 @@ export class VideosCommand extends AbstractCommand {
234 } 234 }
235 235
236 listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { 236 listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & {
237 accountName: string 237 handle: string
238 }) { 238 }) {
239 const { accountName, search } = options 239 const { handle, search } = options
240 const path = '/api/v1/accounts/' + accountName + '/videos' 240 const path = '/api/v1/accounts/' + handle + '/videos'
241 241
242 return this.getRequestBody<ResultList<Video>>({ 242 return this.getRequestBody<ResultList<Video>>({
243 ...options, 243 ...options,
@@ -250,10 +250,10 @@ export class VideosCommand extends AbstractCommand {
250 } 250 }
251 251
252 listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { 252 listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & {
253 videoChannelName: string 253 handle: string
254 }) { 254 }) {
255 const { videoChannelName } = options 255 const { handle } = options
256 const path = '/api/v1/video-channels/' + videoChannelName + '/videos' 256 const path = '/api/v1/video-channels/' + handle + '/videos'
257 257
258 return this.getRequestBody<ResultList<Video>>({ 258 return this.getRequestBody<ResultList<Video>>({
259 ...options, 259 ...options,
@@ -309,13 +309,13 @@ export class VideosCommand extends AbstractCommand {
309 }) { 309 }) {
310 const path = '/api/v1/videos/' + options.id 310 const path = '/api/v1/videos/' + options.id
311 311
312 return this.deleteRequest({ 312 return unwrapBody(this.deleteRequest({
313 ...options, 313 ...options,
314 314
315 path, 315 path,
316 implicitToken: true, 316 implicitToken: true,
317 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 317 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
318 }) 318 }))
319 } 319 }
320 320
321 async removeAll () { 321 async removeAll () {
@@ -396,7 +396,7 @@ export class VideosCommand extends AbstractCommand {
396 396
397 async buildResumeUpload (options: OverrideCommandOptions & { 397 async buildResumeUpload (options: OverrideCommandOptions & {
398 attributes: VideoEdit 398 attributes: VideoEdit
399 }) { 399 }): Promise<VideoCreateResult> {
400 const { attributes, expectedStatus } = options 400 const { attributes, expectedStatus } = options
401 401
402 let size = 0 402 let size = 0
@@ -414,7 +414,8 @@ export class VideosCommand extends AbstractCommand {
414 } 414 }
415 } 415 }
416 416
417 const initializeSessionRes = await this.prepareResumableUpload({ ...options, attributes, size, mimetype }) 417 // Do not check status automatically, we'll check it manually
418 const initializeSessionRes = await this.prepareResumableUpload({ ...options, expectedStatus: null, attributes, size, mimetype })
418 const initStatus = initializeSessionRes.status 419 const initStatus = initializeSessionRes.status
419 420
420 if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) { 421 if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) {
@@ -425,7 +426,7 @@ export class VideosCommand extends AbstractCommand {
425 426
426 const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size }) 427 const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size })
427 428
428 return result.body.video 429 return result.body?.video || result.body as any
429 } 430 }
430 431
431 const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200 432 const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200
@@ -434,7 +435,7 @@ export class VideosCommand extends AbstractCommand {
434 435
435 expect(initStatus).to.equal(expectedInitStatus) 436 expect(initStatus).to.equal(expectedInitStatus)
436 437
437 return initializeSessionRes.body.video as VideoCreateResult 438 return initializeSessionRes.body.video || initializeSessionRes.body
438 } 439 }
439 440
440 async prepareResumableUpload (options: OverrideCommandOptions & { 441 async prepareResumableUpload (options: OverrideCommandOptions & {
@@ -455,7 +456,10 @@ export class VideosCommand extends AbstractCommand {
455 'X-Upload-Content-Length': size.toString() 456 'X-Upload-Content-Length': size.toString()
456 }, 457 },
457 fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) }, 458 fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) },
459 // Fixture will be sent later
460 attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')),
458 implicitToken: true, 461 implicitToken: true,
462
459 defaultExpectedStatus: null 463 defaultExpectedStatus: null
460 }) 464 })
461 } 465 }
@@ -539,10 +543,10 @@ export class VideosCommand extends AbstractCommand {
539 543
540 const attributes = { name, additionalParams } 544 const attributes = { name, additionalParams }
541 545
542 if (wait) await waitJobs([ this.server ])
543
544 const result = await this.upload({ ...options, attributes }) 546 const result = await this.upload({ ...options, attributes })
545 547
548 if (wait) await waitJobs([ this.server ])
549
546 return { ...result, name } 550 return { ...result, name }
547 } 551 }
548 552
@@ -566,7 +570,7 @@ export class VideosCommand extends AbstractCommand {
566 } 570 }
567 571
568 private buildUploadFields (attributes: VideoEdit) { 572 private buildUploadFields (attributes: VideoEdit) {
569 return omit(attributes, [ 'thumbnailfile', 'previewfile' ]) 573 return omit(attributes, [ 'fixture', 'thumbnailfile', 'previewfile' ])
570 } 574 }
571 575
572 private buildUploadAttaches (attributes: VideoEdit) { 576 private buildUploadAttaches (attributes: VideoEdit) {
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index b41533808..a96073c56 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra' 4import { pathExists, readdir } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { getLowercaseExtension } from '@server/helpers/core-utils' 6import { getLowercaseExtension } from '@server/helpers/core-utils'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 8import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
9import { dateIsValid, testImage, webtorrentAdd } from '../miscs' 9import { dateIsValid, testImage, webtorrentAdd } from '../miscs'
10import { makeRawRequest } from '../requests/requests' 10import { makeRawRequest } from '../requests/requests'