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/captions-command.ts4
-rw-r--r--shared/extra-utils/videos/live-command.ts7
-rw-r--r--shared/extra-utils/videos/live.ts4
-rw-r--r--shared/extra-utils/videos/playlists.ts2
-rw-r--r--shared/extra-utils/videos/videos.ts30
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 @@
1import { HttpStatusCode } from '@shared/core-utils'
1import { ResultList, VideoCaption } from '@shared/models' 2import { ResultList, VideoCaption } from '@shared/models'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 3import { buildAbsoluteFixturePath } from '../miscs'
3import { buildAbsoluteFixturePath } from '../miscs/miscs'
4import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
5 5
6export class CaptionsCommand extends AbstractCommand { 6export 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'
5import { join } from 'path' 5import { join } from 'path'
6import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' 6import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
7import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' 7import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
8import { buildServerDirectory, wait } from '../miscs/miscs' 8import { wait } from '../miscs'
9import { unwrapBody } from '../requests' 9import { unwrapBody } from '../requests'
10import { waitUntilLog } from '../server/servers'
11import { AbstractCommand, OverrideCommandOptions } from '../shared' 10import { AbstractCommand, OverrideCommandOptions } from '../shared'
12import { sendRTMPStream, testFfmpegStreamError } from './live' 11import { sendRTMPStream, testFfmpegStreamError } from './live'
13import { getVideoWithToken } from './videos' 12import { 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'
4import * as ffmpeg from 'fluent-ffmpeg' 4import * as ffmpeg from 'fluent-ffmpeg'
5import { pathExists, readdir } from 'fs-extra' 5import { pathExists, readdir } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs' 7import { buildAbsoluteFixturePath, wait } from '../miscs'
8import { ServerInfo } from '../server/servers' 8import { ServerInfo } from '../server/servers'
9 9
10function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') { 10function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') {
@@ -77,7 +77,7 @@ async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoI
77} 77}
78 78
79async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { 79async 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 @@
1import { expect } from 'chai' 1import { expect } from 'chai'
2import { readdir } from 'fs-extra' 2import { readdir } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { root } from '../' 4import { root } from '../miscs'
5 5
6async function checkPlaylistFilesWereRemoved ( 6async 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'
13import { BooleanBothQuery, VideosCommonQuery } from '@shared/models' 13import { BooleanBothQuery, VideosCommonQuery } from '@shared/models'
14import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 14import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
15import { VideoDetails, VideoPrivacy } from '../../models/videos' 15import { VideoDetails, VideoPrivacy } from '../../models/videos'
16import { 16import { 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'
25import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests' 17import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests'
26import { waitJobs } from '../server/jobs' 18import { waitJobs } from '../server/jobs'
27import { ServerInfo } from '../server/servers' 19import { 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
321async function checkVideoFilesWereRemoved ( 305async 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
607function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { 591function 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)