aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/videos-command.ts
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/videos-command.ts
parentc0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (diff)
downloadPeerTube-4c7e60bc17ee5830399bac4aa273356903421b4c.tar.gz
PeerTube-4c7e60bc17ee5830399bac4aa273356903421b4c.tar.zst
PeerTube-4c7e60bc17ee5830399bac4aa273356903421b4c.zip
Reorganize imports
Diffstat (limited to 'shared/extra-utils/videos/videos-command.ts')
-rw-r--r--shared/extra-utils/videos/videos-command.ts15
1 files changed, 8 insertions, 7 deletions
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