aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 14:27:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:19 +0200
commit4c7e60bc17ee5830399bac4aa273356903421b4c (patch)
tree9e67397cf49b229b5bc0f9747f1a7e387bba558a /shared/extra-utils/videos
parentc0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (diff)
downloadPeerTube-4c7e60bc17ee5830399bac4aa273356903421b4c.tar.gz
PeerTube-4c7e60bc17ee5830399bac4aa273356903421b4c.tar.zst
PeerTube-4c7e60bc17ee5830399bac4aa273356903421b4c.zip
Reorganize imports
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r--shared/extra-utils/videos/blacklist-command.ts3
-rw-r--r--shared/extra-utils/videos/captions-command.ts3
-rw-r--r--shared/extra-utils/videos/change-ownership-command.ts3
-rw-r--r--shared/extra-utils/videos/channels-command.ts3
-rw-r--r--shared/extra-utils/videos/comments-command.ts3
-rw-r--r--shared/extra-utils/videos/history-command.ts3
-rw-r--r--shared/extra-utils/videos/imports-command.ts3
-rw-r--r--shared/extra-utils/videos/live-command.ts3
-rw-r--r--shared/extra-utils/videos/playlists-command.ts2
-rw-r--r--shared/extra-utils/videos/streaming-playlists.ts3
-rw-r--r--shared/extra-utils/videos/videos-command.ts15
-rw-r--r--shared/extra-utils/videos/videos.ts2
12 files changed, 19 insertions, 27 deletions
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts
index 9404d4c08..3a2ef89ba 100644
--- a/shared/extra-utils/videos/blacklist-command.ts
+++ b/shared/extra-utils/videos/blacklist-command.ts
@@ -1,6 +1,5 @@
1 1
2import { ResultList } from '@shared/models' 2import { HttpStatusCode, ResultList } from '@shared/models'
3import { HttpStatusCode } from '@shared/models'
4import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' 3import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'
5import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
6 5
diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts
index 04dd32f84..a0608e1a6 100644
--- a/shared/extra-utils/videos/captions-command.ts
+++ b/shared/extra-utils/videos/captions-command.ts
@@ -1,5 +1,4 @@
1import { HttpStatusCode } from '@shared/models' 1import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models'
2import { ResultList, VideoCaption } from '@shared/models'
3import { buildAbsoluteFixturePath } from '../miscs' 2import { buildAbsoluteFixturePath } from '../miscs'
4import { AbstractCommand, OverrideCommandOptions } from '../shared' 3import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 4
diff --git a/shared/extra-utils/videos/change-ownership-command.ts b/shared/extra-utils/videos/change-ownership-command.ts
index ef6f07536..ad4c726ef 100644
--- a/shared/extra-utils/videos/change-ownership-command.ts
+++ b/shared/extra-utils/videos/change-ownership-command.ts
@@ -1,6 +1,5 @@
1 1
2import { ResultList, VideoChangeOwnership } from '@shared/models' 2import { HttpStatusCode, ResultList, VideoChangeOwnership } from '@shared/models'
3import { HttpStatusCode } from '@shared/models'
4import { AbstractCommand, OverrideCommandOptions } from '../shared' 3import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 4
6export class ChangeOwnershipCommand extends AbstractCommand { 5export class ChangeOwnershipCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts
index e5393ff56..f8eb3f885 100644
--- a/shared/extra-utils/videos/channels-command.ts
+++ b/shared/extra-utils/videos/channels-command.ts
@@ -1,6 +1,5 @@
1import { pick } from 'lodash' 1import { pick } from 'lodash'
2import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' 2import { HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models'
3import { HttpStatusCode } from '@shared/models'
4import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' 3import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'
5import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' 4import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'
6import { unwrapBody } from '../requests' 5import { unwrapBody } from '../requests'
diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts
index 7368f3ea2..dd14e4b64 100644
--- a/shared/extra-utils/videos/comments-command.ts
+++ b/shared/extra-utils/videos/comments-command.ts
@@ -1,6 +1,5 @@
1import { pick } from 'lodash' 1import { pick } from 'lodash'
2import { HttpStatusCode } from '@shared/models' 2import { HttpStatusCode, ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models'
3import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models'
4import { unwrapBody } from '../requests' 3import { unwrapBody } from '../requests'
5import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
6 5
diff --git a/shared/extra-utils/videos/history-command.ts b/shared/extra-utils/videos/history-command.ts
index 41afc6bc6..13b7150c1 100644
--- a/shared/extra-utils/videos/history-command.ts
+++ b/shared/extra-utils/videos/history-command.ts
@@ -1,5 +1,4 @@
1import { HttpStatusCode } from '@shared/models' 1import { HttpStatusCode, ResultList, Video } from '@shared/models'
2import { ResultList, Video } from '@shared/models'
3import { AbstractCommand, OverrideCommandOptions } from '../shared' 2import { AbstractCommand, OverrideCommandOptions } from '../shared'
4 3
5export class HistoryCommand extends AbstractCommand { 4export class HistoryCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts
index d30f9745b..e4944694d 100644
--- a/shared/extra-utils/videos/imports-command.ts
+++ b/shared/extra-utils/videos/imports-command.ts
@@ -1,6 +1,5 @@
1 1
2import { HttpStatusCode } from '@shared/models' 2import { HttpStatusCode, ResultList } from '@shared/models'
3import { ResultList } from '@shared/models'
4import { VideoImport, VideoImportCreate } from '../../models/videos' 3import { VideoImport, VideoImportCreate } from '../../models/videos'
5import { unwrapBody } from '../requests' 4import { unwrapBody } from '../requests'
6import { AbstractCommand, OverrideCommandOptions } from '../shared' 5import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts
index 9dfe3087e..bf9486a05 100644
--- a/shared/extra-utils/videos/live-command.ts
+++ b/shared/extra-utils/videos/live-command.ts
@@ -3,8 +3,7 @@
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 { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
7import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
8import { wait } from '../miscs' 7import { wait } from '../miscs'
9import { unwrapBody } from '../requests' 8import { unwrapBody } from '../requests'
10import { AbstractCommand, OverrideCommandOptions } from '../shared' 9import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts
index 40162c30d..6f329800e 100644
--- a/shared/extra-utils/videos/playlists-command.ts
+++ b/shared/extra-utils/videos/playlists-command.ts
@@ -1,7 +1,7 @@
1import { omit, pick } from 'lodash' 1import { omit, pick } from 'lodash'
2import { HttpStatusCode } from '@shared/models'
3import { 2import {
4 BooleanBothQuery, 3 BooleanBothQuery,
4 HttpStatusCode,
5 ResultList, 5 ResultList,
6 VideoExistInPlaylist, 6 VideoExistInPlaylist,
7 VideoPlaylist, 7 VideoPlaylist,
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts
index 007d3d98d..1ae3fefc1 100644
--- a/shared/extra-utils/videos/streaming-playlists.ts
+++ b/shared/extra-utils/videos/streaming-playlists.ts
@@ -1,7 +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/models' 3import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'
4import { VideoStreamingPlaylist } from '@shared/models'
5import { PeerTubeServer } from '../server' 4import { PeerTubeServer } from '../server'
6 5
7async function checkSegmentHash (options: { 6async function checkSegmentHash (options: {
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts
index f46d386f4..40cc4dc28 100644
--- a/shared/extra-utils/videos/videos-command.ts
+++ b/shared/extra-utils/videos/videos-command.ts
@@ -7,8 +7,8 @@ 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/models'
11import { 10import {
11 HttpStatusCode,
12 ResultList, 12 ResultList,
13 UserVideoRateType, 13 UserVideoRateType,
14 Video, 14 Video,
@@ -332,7 +332,7 @@ export class VideosCommand extends AbstractCommand {
332 attributes?: VideoEdit 332 attributes?: VideoEdit
333 mode?: 'legacy' | 'resumable' // default legacy 333 mode?: 'legacy' | 'resumable' // default legacy
334 } = {}) { 334 } = {}) {
335 const { mode = 'legacy', expectedStatus } = options 335 const { mode = 'legacy' } = options
336 let defaultChannelId = 1 336 let defaultChannelId = 1
337 337
338 try { 338 try {
@@ -360,22 +360,23 @@ export class VideosCommand extends AbstractCommand {
360 ...options.attributes 360 ...options.attributes
361 } 361 }
362 362
363 const res = mode === 'legacy' 363 const created = mode === 'legacy'
364 ? await this.buildLegacyUpload({ ...options, attributes }) 364 ? await this.buildLegacyUpload({ ...options, attributes })
365 : await this.buildResumeUpload({ ...options, attributes }) 365 : await this.buildResumeUpload({ ...options, attributes })
366 366
367 // Wait torrent generation 367 // Wait torrent generation
368 const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 })
368 if (expectedStatus === HttpStatusCode.OK_200) { 369 if (expectedStatus === HttpStatusCode.OK_200) {
369 let video: VideoDetails 370 let video: VideoDetails
370 371
371 do { 372 do {
372 video = await this.getWithToken({ ...options, id: video.uuid }) 373 video = await this.getWithToken({ ...options, id: created.uuid })
373 374
374 await wait(50) 375 await wait(50)
375 } while (!video.files[0].torrentUrl) 376 } while (!video.files[0].torrentUrl)
376 } 377 }
377 378
378 return res 379 return created
379 } 380 }
380 381
381 async buildLegacyUpload (options: OverrideCommandOptions & { 382 async buildLegacyUpload (options: OverrideCommandOptions & {
@@ -535,13 +536,13 @@ export class VideosCommand extends AbstractCommand {
535 536
536 async randomUpload (options: OverrideCommandOptions & { 537 async randomUpload (options: OverrideCommandOptions & {
537 wait?: boolean // default true 538 wait?: boolean // default true
538 additionalParams?: VideoEdit & { prefixName: string } 539 additionalParams?: VideoEdit & { prefixName?: string }
539 } = {}) { 540 } = {}) {
540 const { wait = true, additionalParams } = options 541 const { wait = true, additionalParams } = options
541 const prefixName = additionalParams?.prefixName || '' 542 const prefixName = additionalParams?.prefixName || ''
542 const name = prefixName + buildUUID() 543 const name = prefixName + buildUUID()
543 544
544 const attributes = { name, additionalParams } 545 const attributes = { name, ...additionalParams }
545 546
546 const result = await this.upload({ ...options, attributes }) 547 const result = await this.upload({ ...options, attributes })
547 548
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index a96073c56..9a9bfb3cf 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -202,7 +202,7 @@ async function uploadRandomVideoOnServers (
202 additionalParams?: VideoEdit & { prefixName?: string } 202 additionalParams?: VideoEdit & { prefixName?: string }
203) { 203) {
204 const server = servers.find(s => s.serverNumber === serverNumber) 204 const server = servers.find(s => s.serverNumber === serverNumber)
205 const res = await server.videos.randomUpload({ wait: false, ...additionalParams }) 205 const res = await server.videos.randomUpload({ wait: false, additionalParams })
206 206
207 await waitJobs(servers) 207 await waitJobs(servers)
208 208