1
0
Fork 0

Rename streaming playlists routes/directories

This commit is contained in:
Chocobozzz 2019-03-05 12:00:31 +01:00 committed by Chocobozzz
parent 09979f8959
commit 9c6ca37fc1
12 changed files with 34 additions and 27 deletions

View file

@ -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' import { Video } from '@app/shared/video/video.model'
export class VideosOverview implements VideosOverviewServer { export class VideosOverview implements VideosOverviewServer {
channels: { channels: {
channel: VideoChannelAttribute channel: VideoChannelSummary
videos: Video[] videos: Video[]
}[] }[]

View file

@ -48,7 +48,7 @@ storage:
tmp: 'storage/tmp/' # Used to download data (imports etc), store uploaded files before processing... tmp: 'storage/tmp/' # Used to download data (imports etc), store uploaded files before processing...
avatars: 'storage/avatars/' avatars: 'storage/avatars/'
videos: 'storage/videos/' videos: 'storage/videos/'
playlists: 'storage/playlists/' streaming_playlists: 'storage/streaming-playlists/'
redundancy: 'storage/redundancy/' redundancy: 'storage/redundancy/'
logs: 'storage/logs/' logs: 'storage/logs/'
previews: 'storage/previews/' previews: 'storage/previews/'

View file

@ -124,7 +124,7 @@ activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:f
executeIfActivityPub(asyncMiddleware(videoFileRedundancyGetValidator)), executeIfActivityPub(asyncMiddleware(videoFileRedundancyGetValidator)),
executeIfActivityPub(asyncMiddleware(videoRedundancyController)) executeIfActivityPub(asyncMiddleware(videoRedundancyController))
) )
activityPubClientRouter.get('/redundancy/video-playlists/:streamingPlaylistType/:videoId', activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId',
executeIfActivityPub(asyncMiddleware(videoPlaylistRedundancyGetValidator)), executeIfActivityPub(asyncMiddleware(videoPlaylistRedundancyGetValidator)),
executeIfActivityPub(asyncMiddleware(videoRedundancyController)) executeIfActivityPub(asyncMiddleware(videoRedundancyController))
) )

View file

@ -1,6 +1,13 @@
import * as cors from 'cors' import * as cors from 'cors'
import * as express from 'express' 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 { VideosPreviewCache } from '../lib/cache'
import { cacheRoute } from '../middlewares/cache' import { cacheRoute } from '../middlewares/cache'
import { asyncMiddleware, videosGetValidator } from '../middlewares' import { asyncMiddleware, videosGetValidator } from '../middlewares'
@ -53,9 +60,9 @@ staticRouter.use(
// HLS // HLS
staticRouter.use( staticRouter.use(
STATIC_PATHS.PLAYLISTS.HLS, STATIC_PATHS.STREAMING_PLAYLISTS.HLS,
cors(), 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 // Thumbnails path for express

View file

@ -12,7 +12,7 @@ function checkMissedConfig () {
'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', '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', '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.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', 'log.level',
'user.video_quota', 'user.video_quota_daily', 'user.video_quota', 'user.video_quota_daily',
'csp.enabled', 'csp.report_only', 'csp.report_uri', 'csp.enabled', 'csp.report_only', 'csp.report_uri',

View file

@ -196,7 +196,7 @@ const CONFIG = {
AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
LOG_DIR: buildPath(config.get<string>('storage.logs')), LOG_DIR: buildPath(config.get<string>('storage.logs')),
VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
PLAYLISTS_DIR: buildPath(config.get<string>('storage.playlists')), STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')),
REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')), REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
@ -625,8 +625,8 @@ const STATIC_PATHS = {
TORRENTS: '/static/torrents/', TORRENTS: '/static/torrents/',
WEBSEED: '/static/webseed/', WEBSEED: '/static/webseed/',
REDUNDANCY: '/static/redundancy/', REDUNDANCY: '/static/redundancy/',
PLAYLISTS: { STREAMING_PLAYLISTS: {
HLS: '/static/playlists/hls' HLS: '/static/streaming-playlists/hls'
}, },
AVATARS: '/static/avatars/', AVATARS: '/static/avatars/',
VIDEO_CAPTIONS: '/static/video-captions/' 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 HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
const MEMOIZE_TTL = { const MEMOIZE_TTL = {
@ -777,7 +777,7 @@ export {
PRIVATE_RSA_KEY_SIZE, PRIVATE_RSA_KEY_SIZE,
ROUTE_CACHE_LIFETIME, ROUTE_CACHE_LIFETIME,
SORTABLE_COLUMNS, SORTABLE_COLUMNS,
HLS_PLAYLIST_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY,
FEEDS, FEEDS,
JOB_TTL, JOB_TTL,
NSFW_POLICY_TYPES, NSFW_POLICY_TYPES,

View file

@ -6,7 +6,7 @@ import { UserModel } from '../models/account/user'
import { ApplicationModel } from '../models/application/application' import { ApplicationModel } from '../models/application/application'
import { OAuthClientModel } from '../models/oauth/oauth-client' import { OAuthClientModel } from '../models/oauth/oauth-client'
import { applicationExist, clientsExist, usersExist } from './checker-after-init' 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 { sequelizeTypescript } from './database'
import { remove, ensureDir } from 'fs-extra' import { remove, ensureDir } from 'fs-extra'
@ -74,7 +74,7 @@ function createDirectoriesIfNotExist () {
} }
// Playlist directories // Playlist directories
tasks.push(ensureDir(HLS_PLAYLIST_DIRECTORY)) tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY))
return Promise.all(tasks) return Promise.all(tasks)
} }

View file

@ -27,7 +27,7 @@ function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
} }
function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { 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) { function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {

View file

@ -1,6 +1,6 @@
import { VideoModel } from '../models/video/video' import { VideoModel } from '../models/video/video'
import { basename, join, dirname } from 'path' 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 { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra'
import { getVideoFileSize } from '../helpers/ffmpeg-utils' import { getVideoFileSize } from '../helpers/ffmpeg-utils'
import { sha256 } from '../helpers/core-utils' import { sha256 } from '../helpers/core-utils'
@ -11,7 +11,7 @@ import { generateRandomString } from '../helpers/utils'
import { flatten, uniq } from 'lodash' import { flatten, uniq } from 'lodash'
async function updateMasterHLSPlaylist (video: VideoModel) { 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 masterPlaylists: string[] = [ '#EXTM3U', '#EXT-X-VERSION:3' ]
const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename()) const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename())
@ -40,7 +40,7 @@ async function updateMasterHLSPlaylist (video: VideoModel) {
async function updateSha256Segments (video: VideoModel) { async function updateSha256Segments (video: VideoModel) {
const json: { [filename: string]: { [range: string]: string } } = {} 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 all the resolutions available for this video
for (const file of video.VideoFiles) { for (const file of video.VideoFiles) {

View file

@ -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 { extname, join } from 'path'
import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils'
import { copy, ensureDir, move, remove, stat } from 'fs-extra' 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) { async function generateHlsPlaylist (video: VideoModel, resolution: VideoResolution, isPortraitMode: boolean) {
const baseHlsDirectory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
await ensureDir(join(HLS_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 videoInputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(video.getOriginalFile()))
const outputPath = join(baseHlsDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) const outputPath = join(baseHlsDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution))

View file

@ -130,15 +130,15 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod
} }
static getHlsMasterPlaylistStaticPath (videoUUID: string) { static getHlsMasterPlaylistStaticPath (videoUUID: string) {
return join(STATIC_PATHS.PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename()) return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename())
} }
static getHlsPlaylistStaticPath (videoUUID: string, resolution: number) { static getHlsPlaylistStaticPath (videoUUID: string, resolution: number) {
return join(STATIC_PATHS.PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution))
} }
static getHlsSha256SegmentsStaticPath (videoUUID: string) { static getHlsSha256SegmentsStaticPath (videoUUID: string) {
return join(STATIC_PATHS.PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsSha256SegmentsFilename()) return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsSha256SegmentsFilename())
} }
getStringType () { getStringType () {

View file

@ -53,7 +53,7 @@ import {
API_VERSION, API_VERSION,
CONFIG, CONFIG,
CONSTRAINTS_FIELDS, CONSTRAINTS_FIELDS,
HLS_PLAYLIST_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY,
HLS_REDUNDANCY_DIRECTORY, HLS_REDUNDANCY_DIRECTORY,
PREVIEWS_SIZE, PREVIEWS_SIZE,
REMOTE_SCHEME, REMOTE_SCHEME,
@ -1751,7 +1751,7 @@ export class VideoModel extends Model<VideoModel> {
} }
removeStreamingPlaylist (isRedundancy = false) { 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) const filePath = join(baseDir, this.uuid)
return remove(filePath) return remove(filePath)