aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 09:43:59 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit6c5065a011b099618681a37bd77eaa7bd3db752e (patch)
tree352252a00b25013c4b1902f6bcd9668aba295c7b /shared/extra-utils/videos/videos.ts
parent0d8ecb7592577f54012413a2b5a9b159cfc90399 (diff)
downloadPeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.gz
PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.zst
PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.zip
Introduce server commands
Diffstat (limited to 'shared/extra-utils/videos/videos.ts')
-rw-r--r--shared/extra-utils/videos/videos.ts30
1 files changed, 7 insertions, 23 deletions
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)