From 092092969633bbcf6d4891a083ea497a7d5c3154 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Jan 2019 08:37:25 +0100 Subject: Add hls support on server --- shared/utils/index.ts | 2 ++ shared/utils/requests/requests.ts | 13 ++++++++++--- shared/utils/server/config.ts | 3 +++ shared/utils/server/servers.ts | 7 ++++++- shared/utils/videos/video-playlists.ts | 21 +++++++++++++++++++++ shared/utils/videos/videos.ts | 13 +++++++++++-- 6 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 shared/utils/videos/video-playlists.ts (limited to 'shared/utils') diff --git a/shared/utils/index.ts b/shared/utils/index.ts index e08bbfd2a..156901372 100644 --- a/shared/utils/index.ts +++ b/shared/utils/index.ts @@ -17,6 +17,8 @@ export * from './users/users' export * from './videos/video-abuses' export * from './videos/video-blacklist' export * from './videos/video-channels' +export * from './videos/video-comments' +export * from './videos/video-playlists' export * from './videos/videos' export * from './videos/video-change-ownership' export * from './feeds/feeds' diff --git a/shared/utils/requests/requests.ts b/shared/utils/requests/requests.ts index 77e9f6164..fc687c701 100644 --- a/shared/utils/requests/requests.ts +++ b/shared/utils/requests/requests.ts @@ -1,10 +1,17 @@ import * as request from 'supertest' import { buildAbsoluteFixturePath, root } from '../miscs/miscs' import { isAbsolute, join } from 'path' +import { parse } from 'url' + +function makeRawRequest (url: string, statusCodeExpected?: number) { + const { host, protocol, pathname } = parse(url) + + return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected }) +} function makeGetRequest (options: { url: string, - path: string, + path?: string, query?: any, token?: string, statusCodeExpected?: number, @@ -13,8 +20,7 @@ function makeGetRequest (options: { if (!options.statusCodeExpected) options.statusCodeExpected = 400 if (options.contentType === undefined) options.contentType = 'application/json' - const req = request(options.url) - .get(options.path) + const req = request(options.url).get(options.path) if (options.contentType) req.set('Accept', options.contentType) if (options.token) req.set('Authorization', 'Bearer ' + options.token) @@ -164,5 +170,6 @@ export { makePostBodyRequest, makePutBodyRequest, makeDeleteRequest, + makeRawRequest, updateAvatarRequest } diff --git a/shared/utils/server/config.ts b/shared/utils/server/config.ts index 0c5512bab..29c24cff9 100644 --- a/shared/utils/server/config.ts +++ b/shared/utils/server/config.ts @@ -97,6 +97,9 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { '480p': true, '720p': false, '1080p': false + }, + hls: { + enabled: false } }, import: { diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts index cb57e0a69..bde7dd5c2 100644 --- a/shared/utils/server/servers.ts +++ b/shared/utils/server/servers.ts @@ -166,9 +166,13 @@ async function reRunServer (server: ServerInfo, configOverride?: any) { } async function checkTmpIsEmpty (server: ServerInfo) { + return checkDirectoryIsEmpty(server, 'tmp') +} + +async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { const testDirectory = 'test' + server.serverNumber - const directoryPath = join(root(), testDirectory, 'tmp') + const directoryPath = join(root(), testDirectory, directory) const directoryExists = existsSync(directoryPath) expect(directoryExists).to.be.true @@ -199,6 +203,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1) { // --------------------------------------------------------------------------- export { + checkDirectoryIsEmpty, checkTmpIsEmpty, ServerInfo, flushAndRunMultipleServers, diff --git a/shared/utils/videos/video-playlists.ts b/shared/utils/videos/video-playlists.ts new file mode 100644 index 000000000..9a0710ca6 --- /dev/null +++ b/shared/utils/videos/video-playlists.ts @@ -0,0 +1,21 @@ +import { makeRawRequest } from '../requests/requests' + +function getPlaylist (url: string, statusCodeExpected = 200) { + return makeRawRequest(url, statusCodeExpected) +} + +function getSegment (url: string, statusCodeExpected = 200) { + return makeRawRequest(url, statusCodeExpected) +} + +function getSegmentSha256 (url: string, statusCodeExpected = 200) { + return makeRawRequest(url, statusCodeExpected) +} + +// --------------------------------------------------------------------------- + +export { + getPlaylist, + getSegment, + getSegmentSha256 +} diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts index 0cf6e7c4f..b5b33e038 100644 --- a/shared/utils/videos/videos.ts +++ b/shared/utils/videos/videos.ts @@ -271,7 +271,16 @@ function removeVideo (url: string, token: string, id: number | string, expectedS async function checkVideoFilesWereRemoved ( videoUUID: string, serverNumber: number, - directories = [ 'redundancy', 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ] + directories = [ + 'redundancy', + 'videos', + 'thumbnails', + 'torrents', + 'previews', + 'captions', + join('playlists', 'hls'), + join('redundancy', 'hls') + ] ) { const testDirectory = 'test' + serverNumber @@ -279,7 +288,7 @@ async function checkVideoFilesWereRemoved ( const directoryPath = join(root(), testDirectory, directory) const directoryExists = existsSync(directoryPath) - expect(directoryExists).to.be.true + if (!directoryExists) continue const files = await readdir(directoryPath) for (const file of files) { -- cgit v1.2.3