From 9c6ca37fc1512a99d420ea90707cebcd06cdc970 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 5 Mar 2019 12:00:31 +0100 Subject: [PATCH] Rename streaming playlists routes/directories --- .../app/shared/overview/videos-overview.model.ts | 4 ++-- config/default.yaml | 2 +- server/controllers/activitypub/client.ts | 2 +- server/controllers/static.ts | 13 ++++++++++--- server/initializers/checker-before-init.ts | 2 +- server/initializers/constants.ts | 10 +++++----- server/initializers/installer.ts | 4 ++-- server/lib/activitypub/url.ts | 2 +- server/lib/hls.ts | 6 +++--- server/lib/video-transcoding.ts | 6 +++--- server/models/video/video-streaming-playlist.ts | 6 +++--- server/models/video/video.ts | 4 ++-- 12 files changed, 34 insertions(+), 27 deletions(-) diff --git a/client/src/app/shared/overview/videos-overview.model.ts b/client/src/app/shared/overview/videos-overview.model.ts index c8eafc8e8..21abe1697 100644 --- a/client/src/app/shared/overview/videos-overview.model.ts +++ b/client/src/app/shared/overview/videos-overview.model.ts @@ -1,9 +1,9 @@ -import { VideoChannelAttribute, VideoConstant, VideosOverview as VideosOverviewServer } from '../../../../../shared/models' +import { VideoChannelSummary, VideoConstant, VideosOverview as VideosOverviewServer } from '../../../../../shared/models' import { Video } from '@app/shared/video/video.model' export class VideosOverview implements VideosOverviewServer { channels: { - channel: VideoChannelAttribute + channel: VideoChannelSummary videos: Video[] }[] diff --git a/config/default.yaml b/config/default.yaml index 6c339e66d..c5bf8e457 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -48,7 +48,7 @@ storage: tmp: 'storage/tmp/' # Used to download data (imports etc), store uploaded files before processing... avatars: 'storage/avatars/' videos: 'storage/videos/' - playlists: 'storage/playlists/' + streaming_playlists: 'storage/streaming-playlists/' redundancy: 'storage/redundancy/' logs: 'storage/logs/' previews: 'storage/previews/' diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index f616047b0..0d1dff96f 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -124,7 +124,7 @@ activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:f executeIfActivityPub(asyncMiddleware(videoFileRedundancyGetValidator)), executeIfActivityPub(asyncMiddleware(videoRedundancyController)) ) -activityPubClientRouter.get('/redundancy/video-playlists/:streamingPlaylistType/:videoId', +activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId', executeIfActivityPub(asyncMiddleware(videoPlaylistRedundancyGetValidator)), executeIfActivityPub(asyncMiddleware(videoRedundancyController)) ) diff --git a/server/controllers/static.ts b/server/controllers/static.ts index b21f9da00..639445b74 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -1,6 +1,13 @@ import * as cors from 'cors' import * as express from 'express' -import { CONFIG, HLS_PLAYLIST_DIRECTORY, ROUTE_CACHE_LIFETIME, STATIC_DOWNLOAD_PATHS, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers' +import { + CONFIG, + HLS_STREAMING_PLAYLIST_DIRECTORY, + ROUTE_CACHE_LIFETIME, + STATIC_DOWNLOAD_PATHS, + STATIC_MAX_AGE, + STATIC_PATHS +} from '../initializers' import { VideosPreviewCache } from '../lib/cache' import { cacheRoute } from '../middlewares/cache' import { asyncMiddleware, videosGetValidator } from '../middlewares' @@ -53,9 +60,9 @@ staticRouter.use( // HLS staticRouter.use( - STATIC_PATHS.PLAYLISTS.HLS, + STATIC_PATHS.STREAMING_PLAYLISTS.HLS, cors(), - express.static(HLS_PLAYLIST_DIRECTORY, { fallthrough: false }) // 404 if the file does not exist + express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }) // 404 if the file does not exist ) // Thumbnails path for express diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 2567d957b..3e1d2c589 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts @@ -12,7 +12,7 @@ function checkMissedConfig () { 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', - 'storage.redundancy', 'storage.tmp', 'storage.playlists', + 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'log.level', 'user.video_quota', 'user.video_quota_daily', 'csp.enabled', 'csp.report_only', 'csp.report_uri', diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 59c30fdee..cabb0681a 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -196,7 +196,7 @@ const CONFIG = { AVATARS_DIR: buildPath(config.get('storage.avatars')), LOG_DIR: buildPath(config.get('storage.logs')), VIDEOS_DIR: buildPath(config.get('storage.videos')), - PLAYLISTS_DIR: buildPath(config.get('storage.playlists')), + STREAMING_PLAYLISTS_DIR: buildPath(config.get('storage.streaming_playlists')), REDUNDANCY_DIR: buildPath(config.get('storage.redundancy')), THUMBNAILS_DIR: buildPath(config.get('storage.thumbnails')), PREVIEWS_DIR: buildPath(config.get('storage.previews')), @@ -625,8 +625,8 @@ const STATIC_PATHS = { TORRENTS: '/static/torrents/', WEBSEED: '/static/webseed/', REDUNDANCY: '/static/redundancy/', - PLAYLISTS: { - HLS: '/static/playlists/hls' + STREAMING_PLAYLISTS: { + HLS: '/static/streaming-playlists/hls' }, AVATARS: '/static/avatars/', VIDEO_CAPTIONS: '/static/video-captions/' @@ -670,7 +670,7 @@ const CACHE = { } } -const HLS_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.PLAYLISTS_DIR, 'hls') +const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls') const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') const MEMOIZE_TTL = { @@ -777,7 +777,7 @@ export { PRIVATE_RSA_KEY_SIZE, ROUTE_CACHE_LIFETIME, SORTABLE_COLUMNS, - HLS_PLAYLIST_DIRECTORY, + HLS_STREAMING_PLAYLIST_DIRECTORY, FEEDS, JOB_TTL, NSFW_POLICY_TYPES, diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index c669606f8..349d7afb7 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts @@ -6,7 +6,7 @@ import { UserModel } from '../models/account/user' import { ApplicationModel } from '../models/application/application' import { OAuthClientModel } from '../models/oauth/oauth-client' import { applicationExist, clientsExist, usersExist } from './checker-after-init' -import { CACHE, CONFIG, HLS_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' +import { CACHE, CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' import { sequelizeTypescript } from './database' import { remove, ensureDir } from 'fs-extra' @@ -74,7 +74,7 @@ function createDirectoriesIfNotExist () { } // Playlist directories - tasks.push(ensureDir(HLS_PLAYLIST_DIRECTORY)) + tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY)) return Promise.all(tasks) } diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts index c80b09436..7c2ee5bc6 100644 --- a/server/lib/activitypub/url.ts +++ b/server/lib/activitypub/url.ts @@ -27,7 +27,7 @@ function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { } function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { - return `${CONFIG.WEBSERVER.URL}/redundancy/video-playlists/${playlist.getStringType()}/${video.uuid}` + return `${CONFIG.WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` } function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { diff --git a/server/lib/hls.ts b/server/lib/hls.ts index 16a805ac2..74ed25183 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts @@ -1,6 +1,6 @@ import { VideoModel } from '../models/video/video' import { basename, join, dirname } from 'path' -import { CONFIG, HLS_PLAYLIST_DIRECTORY } from '../initializers' +import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY } from '../initializers' import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' import { getVideoFileSize } from '../helpers/ffmpeg-utils' import { sha256 } from '../helpers/core-utils' @@ -11,7 +11,7 @@ import { generateRandomString } from '../helpers/utils' import { flatten, uniq } from 'lodash' async function updateMasterHLSPlaylist (video: VideoModel) { - const directory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) + const directory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) const masterPlaylists: string[] = [ '#EXTM3U', '#EXT-X-VERSION:3' ] const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename()) @@ -40,7 +40,7 @@ async function updateMasterHLSPlaylist (video: VideoModel) { async function updateSha256Segments (video: VideoModel) { const json: { [filename: string]: { [range: string]: string } } = {} - const playlistDirectory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) + const playlistDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) // For all the resolutions available for this video for (const file of video.VideoFiles) { diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 086b860a2..e932c0e55 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -1,4 +1,4 @@ -import { CONFIG, HLS_PLAYLIST_DIRECTORY } from '../initializers' +import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY } from '../initializers' import { extname, join } from 'path' import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' import { copy, ensureDir, move, remove, stat } from 'fs-extra' @@ -89,8 +89,8 @@ async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoR } async function generateHlsPlaylist (video: VideoModel, resolution: VideoResolution, isPortraitMode: boolean) { - const baseHlsDirectory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) - await ensureDir(join(HLS_PLAYLIST_DIRECTORY, video.uuid)) + const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) + await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)) const videoInputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(video.getOriginalFile())) const outputPath = join(baseHlsDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index e489f9b0e..b147aca36 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts @@ -130,15 +130,15 @@ export class VideoStreamingPlaylistModel extends Model { } removeStreamingPlaylist (isRedundancy = false) { - const baseDir = isRedundancy ? HLS_REDUNDANCY_DIRECTORY : HLS_PLAYLIST_DIRECTORY + const baseDir = isRedundancy ? HLS_REDUNDANCY_DIRECTORY : HLS_STREAMING_PLAYLIST_DIRECTORY const filePath = join(baseDir, this.uuid) return remove(filePath) -- 2.41.0