diff options
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r-- | shared/extra-utils/videos/captions-command.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/videos/live-command.ts | 7 | ||||
-rw-r--r-- | shared/extra-utils/videos/live.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/videos/playlists.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 30 |
5 files changed, 15 insertions, 32 deletions
diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts index 908b6dae6..ac3bde7a9 100644 --- a/shared/extra-utils/videos/captions-command.ts +++ b/shared/extra-utils/videos/captions-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | ||
1 | import { ResultList, VideoCaption } from '@shared/models' | 2 | import { ResultList, VideoCaption } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { buildAbsoluteFixturePath } from '../miscs' |
3 | import { buildAbsoluteFixturePath } from '../miscs/miscs' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
6 | export class CaptionsCommand extends AbstractCommand { | 6 | export class CaptionsCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index 4f03c9127..a494e60fa 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts | |||
@@ -5,9 +5,8 @@ import { omit } from 'lodash' | |||
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' | 6 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' |
7 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' |
8 | import { buildServerDirectory, wait } from '../miscs/miscs' | 8 | import { wait } from '../miscs' |
9 | import { unwrapBody } from '../requests' | 9 | import { unwrapBody } from '../requests' |
10 | import { waitUntilLog } from '../server/servers' | ||
11 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 10 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
12 | import { sendRTMPStream, testFfmpegStreamError } from './live' | 11 | import { sendRTMPStream, testFfmpegStreamError } from './live' |
13 | import { getVideoWithToken } from './videos' | 12 | import { getVideoWithToken } from './videos' |
@@ -116,7 +115,7 @@ export class LiveCommand extends AbstractCommand { | |||
116 | const { resolution, segment, videoUUID } = options | 115 | const { resolution, segment, videoUUID } = options |
117 | const segmentName = `${resolution}-00000${segment}.ts` | 116 | const segmentName = `${resolution}-00000${segment}.ts` |
118 | 117 | ||
119 | return waitUntilLog(this.server, `${videoUUID}/${segmentName}`, 2, false) | 118 | return this.server.serversCommand.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false) |
120 | } | 119 | } |
121 | 120 | ||
122 | async waitUntilSaved (options: OverrideCommandOptions & { | 121 | async waitUntilSaved (options: OverrideCommandOptions & { |
@@ -135,7 +134,7 @@ export class LiveCommand extends AbstractCommand { | |||
135 | async countPlaylists (options: OverrideCommandOptions & { | 134 | async countPlaylists (options: OverrideCommandOptions & { |
136 | videoUUID: string | 135 | videoUUID: string |
137 | }) { | 136 | }) { |
138 | const basePath = buildServerDirectory(this.server, 'streaming-playlists') | 137 | const basePath = this.server.serversCommand.buildDirectory('streaming-playlists') |
139 | const hlsPath = join(basePath, 'hls', options.videoUUID) | 138 | const hlsPath = join(basePath, 'hls', options.videoUUID) |
140 | 139 | ||
141 | const files = await readdir(hlsPath) | 140 | const files = await readdir(hlsPath) |
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts index 92cb9104c..0efcc2883 100644 --- a/shared/extra-utils/videos/live.ts +++ b/shared/extra-utils/videos/live.ts | |||
@@ -4,7 +4,7 @@ import { expect } from 'chai' | |||
4 | import * as ffmpeg from 'fluent-ffmpeg' | 4 | import * as ffmpeg from 'fluent-ffmpeg' |
5 | import { pathExists, readdir } from 'fs-extra' | 5 | import { pathExists, readdir } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs' | 7 | import { buildAbsoluteFixturePath, wait } from '../miscs' |
8 | import { ServerInfo } from '../server/servers' | 8 | import { ServerInfo } from '../server/servers' |
9 | 9 | ||
10 | function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') { | 10 | function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') { |
@@ -77,7 +77,7 @@ async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoI | |||
77 | } | 77 | } |
78 | 78 | ||
79 | async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { | 79 | async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { |
80 | const basePath = buildServerDirectory(server, 'streaming-playlists') | 80 | const basePath = server.serversCommand.buildDirectory('streaming-playlists') |
81 | const hlsPath = join(basePath, 'hls', videoUUID) | 81 | const hlsPath = join(basePath, 'hls', videoUUID) |
82 | 82 | ||
83 | if (resolutions.length === 0) { | 83 | if (resolutions.length === 0) { |
diff --git a/shared/extra-utils/videos/playlists.ts b/shared/extra-utils/videos/playlists.ts index 023333c87..3dde52bb9 100644 --- a/shared/extra-utils/videos/playlists.ts +++ b/shared/extra-utils/videos/playlists.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { readdir } from 'fs-extra' | 2 | import { readdir } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root } from '../' | 4 | import { root } from '../miscs' |
5 | 5 | ||
6 | async function checkPlaylistFilesWereRemoved ( | 6 | async function checkPlaylistFilesWereRemoved ( |
7 | playlistUUID: string, | 7 | playlistUUID: string, |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 920c93072..5dd71ce8b 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -13,15 +13,7 @@ import { HttpStatusCode } from '@shared/core-utils' | |||
13 | import { BooleanBothQuery, VideosCommonQuery } from '@shared/models' | 13 | import { BooleanBothQuery, VideosCommonQuery } from '@shared/models' |
14 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' | 14 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' |
15 | import { VideoDetails, VideoPrivacy } from '../../models/videos' | 15 | import { VideoDetails, VideoPrivacy } from '../../models/videos' |
16 | import { | 16 | import { buildAbsoluteFixturePath, dateIsValid, testImage, wait, webtorrentAdd } from '../miscs' |
17 | buildAbsoluteFixturePath, | ||
18 | buildServerDirectory, | ||
19 | dateIsValid, | ||
20 | immutableAssign, | ||
21 | testImage, | ||
22 | wait, | ||
23 | webtorrentAdd | ||
24 | } from '../miscs/miscs' | ||
25 | import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests' | 17 | import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests' |
26 | import { waitJobs } from '../server/jobs' | 18 | import { waitJobs } from '../server/jobs' |
27 | import { ServerInfo } from '../server/servers' | 19 | import { ServerInfo } from '../server/servers' |
@@ -165,7 +157,7 @@ function getVideosListWithToken (url: string, token: string, query: { nsfw?: Boo | |||
165 | return request(url) | 157 | return request(url) |
166 | .get(path) | 158 | .get(path) |
167 | .set('Authorization', 'Bearer ' + token) | 159 | .set('Authorization', 'Bearer ' + token) |
168 | .query(immutableAssign(query, { sort: 'name' })) | 160 | .query({ sort: 'name', ...query }) |
169 | .set('Accept', 'application/json') | 161 | .set('Accept', 'application/json') |
170 | .expect(HttpStatusCode.OK_200) | 162 | .expect(HttpStatusCode.OK_200) |
171 | .expect('Content-Type', /json/) | 163 | .expect('Content-Type', /json/) |
@@ -228,11 +220,7 @@ function getAccountVideos ( | |||
228 | return makeGetRequest({ | 220 | return makeGetRequest({ |
229 | url, | 221 | url, |
230 | path, | 222 | path, |
231 | query: immutableAssign(query, { | 223 | query: { ...query, start, count, sort }, |
232 | start, | ||
233 | count, | ||
234 | sort | ||
235 | }), | ||
236 | token: accessToken, | 224 | token: accessToken, |
237 | statusCodeExpected: HttpStatusCode.OK_200 | 225 | statusCodeExpected: HttpStatusCode.OK_200 |
238 | }) | 226 | }) |
@@ -252,11 +240,7 @@ function getVideoChannelVideos ( | |||
252 | return makeGetRequest({ | 240 | return makeGetRequest({ |
253 | url, | 241 | url, |
254 | path, | 242 | path, |
255 | query: immutableAssign(query, { | 243 | query: { ...query, start, count, sort }, |
256 | start, | ||
257 | count, | ||
258 | sort | ||
259 | }), | ||
260 | token: accessToken, | 244 | token: accessToken, |
261 | statusCodeExpected: HttpStatusCode.OK_200 | 245 | statusCodeExpected: HttpStatusCode.OK_200 |
262 | }) | 246 | }) |
@@ -320,7 +304,7 @@ async function removeAllVideos (server: ServerInfo) { | |||
320 | 304 | ||
321 | async function checkVideoFilesWereRemoved ( | 305 | async function checkVideoFilesWereRemoved ( |
322 | videoUUID: string, | 306 | videoUUID: string, |
323 | serverNumber: number, | 307 | server: ServerInfo, |
324 | directories = [ | 308 | directories = [ |
325 | 'redundancy', | 309 | 'redundancy', |
326 | 'videos', | 310 | 'videos', |
@@ -333,7 +317,7 @@ async function checkVideoFilesWereRemoved ( | |||
333 | ] | 317 | ] |
334 | ) { | 318 | ) { |
335 | for (const directory of directories) { | 319 | for (const directory of directories) { |
336 | const directoryPath = buildServerDirectory({ internalServerNumber: serverNumber }, directory) | 320 | const directoryPath = server.serversCommand.buildDirectory(directory) |
337 | 321 | ||
338 | const directoryExists = await pathExists(directoryPath) | 322 | const directoryExists = await pathExists(directoryPath) |
339 | if (directoryExists === false) continue | 323 | if (directoryExists === false) continue |
@@ -607,7 +591,7 @@ function rateVideo (url: string, accessToken: string, id: number | string, ratin | |||
607 | function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { | 591 | function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { |
608 | return new Promise<any>((res, rej) => { | 592 | return new Promise<any>((res, rej) => { |
609 | const torrentName = videoUUID + '-' + resolution + '.torrent' | 593 | const torrentName = videoUUID + '-' + resolution + '.torrent' |
610 | const torrentPath = buildServerDirectory(server, join('torrents', torrentName)) | 594 | const torrentPath = server.serversCommand.buildDirectory(join('torrents', torrentName)) |
611 | 595 | ||
612 | readFile(torrentPath, (err, data) => { | 596 | readFile(torrentPath, (err, data) => { |
613 | if (err) return rej(err) | 597 | if (err) return rej(err) |