From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- shared/extra-utils/videos/blacklist-command.ts | 3 +-- shared/extra-utils/videos/captions-command.ts | 3 +-- shared/extra-utils/videos/change-ownership-command.ts | 3 +-- shared/extra-utils/videos/channels-command.ts | 3 +-- shared/extra-utils/videos/comments-command.ts | 3 +-- shared/extra-utils/videos/history-command.ts | 3 +-- shared/extra-utils/videos/imports-command.ts | 3 +-- shared/extra-utils/videos/live-command.ts | 3 +-- shared/extra-utils/videos/playlists-command.ts | 2 +- shared/extra-utils/videos/streaming-playlists.ts | 3 +-- shared/extra-utils/videos/videos-command.ts | 15 ++++++++------- shared/extra-utils/videos/videos.ts | 2 +- 12 files changed, 19 insertions(+), 27 deletions(-) (limited to 'shared/extra-utils/videos') 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 @@ -import { ResultList } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList } from '@shared/models' import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' import { AbstractCommand, OverrideCommandOptions } from '../shared' 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 @@ -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoCaption } from '@shared/models' +import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models' import { buildAbsoluteFixturePath } from '../miscs' import { AbstractCommand, OverrideCommandOptions } from '../shared' 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 @@ -import { ResultList, VideoChangeOwnership } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList, VideoChangeOwnership } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export 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 @@ import { pick } from 'lodash' -import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' import { 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 @@ import { pick } from 'lodash' -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' +import { HttpStatusCode, ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' import { unwrapBody } from '../requests' import { AbstractCommand, OverrideCommandOptions } from '../shared' 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 @@ -import { HttpStatusCode } from '@shared/models' -import { ResultList, Video } from '@shared/models' +import { HttpStatusCode, ResultList, Video } from '@shared/models' import { AbstractCommand, OverrideCommandOptions } from '../shared' export 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 @@ -import { HttpStatusCode } from '@shared/models' -import { ResultList } from '@shared/models' +import { HttpStatusCode, ResultList } from '@shared/models' import { VideoImport, VideoImportCreate } from '../../models/videos' import { unwrapBody } from '../requests' import { 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 @@ import { readdir } from 'fs-extra' import { omit } from 'lodash' import { join } from 'path' -import { HttpStatusCode } from '@shared/models' -import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' +import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' import { wait } from '../miscs' import { unwrapBody } from '../requests' import { 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 @@ import { omit, pick } from 'lodash' -import { HttpStatusCode } from '@shared/models' import { BooleanBothQuery, + HttpStatusCode, ResultList, VideoExistInPlaylist, 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 @@ import { expect } from 'chai' import { sha256 } from '@server/helpers/core-utils' -import { HttpStatusCode } from '@shared/models' -import { VideoStreamingPlaylist } from '@shared/models' +import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models' import { PeerTubeServer } from '../server' async 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' import validator from 'validator' import { buildUUID } from '@server/helpers/uuid' import { loadLanguages } from '@server/initializers/constants' -import { HttpStatusCode } from '@shared/models' import { + HttpStatusCode, ResultList, UserVideoRateType, Video, @@ -332,7 +332,7 @@ export class VideosCommand extends AbstractCommand { attributes?: VideoEdit mode?: 'legacy' | 'resumable' // default legacy } = {}) { - const { mode = 'legacy', expectedStatus } = options + const { mode = 'legacy' } = options let defaultChannelId = 1 try { @@ -360,22 +360,23 @@ export class VideosCommand extends AbstractCommand { ...options.attributes } - const res = mode === 'legacy' + const created = mode === 'legacy' ? await this.buildLegacyUpload({ ...options, attributes }) : await this.buildResumeUpload({ ...options, attributes }) // Wait torrent generation + const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 }) if (expectedStatus === HttpStatusCode.OK_200) { let video: VideoDetails do { - video = await this.getWithToken({ ...options, id: video.uuid }) + video = await this.getWithToken({ ...options, id: created.uuid }) await wait(50) } while (!video.files[0].torrentUrl) } - return res + return created } async buildLegacyUpload (options: OverrideCommandOptions & { @@ -535,13 +536,13 @@ export class VideosCommand extends AbstractCommand { async randomUpload (options: OverrideCommandOptions & { wait?: boolean // default true - additionalParams?: VideoEdit & { prefixName: string } + additionalParams?: VideoEdit & { prefixName?: string } } = {}) { const { wait = true, additionalParams } = options const prefixName = additionalParams?.prefixName || '' const name = prefixName + buildUUID() - const attributes = { name, additionalParams } + const attributes = { name, ...additionalParams } const result = await this.upload({ ...options, attributes }) 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 ( additionalParams?: VideoEdit & { prefixName?: string } ) { const server = servers.find(s => s.serverNumber === serverNumber) - const res = await server.videos.randomUpload({ wait: false, ...additionalParams }) + const res = await server.videos.randomUpload({ wait: false, additionalParams }) await waitJobs(servers) -- cgit v1.2.3