aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-05 12:00:31 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commit9c6ca37fc1512a99d420ea90707cebcd06cdc970 (patch)
tree2ef8e4c9bc30e911923a5b5c83f18e983553929d /server
parent09979f8959425390b879bce22101a9bc061ae9a0 (diff)
downloadPeerTube-9c6ca37fc1512a99d420ea90707cebcd06cdc970.tar.gz
PeerTube-9c6ca37fc1512a99d420ea90707cebcd06cdc970.tar.zst
PeerTube-9c6ca37fc1512a99d420ea90707cebcd06cdc970.zip
Rename streaming playlists routes/directories
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/client.ts2
-rw-r--r--server/controllers/static.ts13
-rw-r--r--server/initializers/checker-before-init.ts2
-rw-r--r--server/initializers/constants.ts10
-rw-r--r--server/initializers/installer.ts4
-rw-r--r--server/lib/activitypub/url.ts2
-rw-r--r--server/lib/hls.ts6
-rw-r--r--server/lib/video-transcoding.ts6
-rw-r--r--server/models/video/video-streaming-playlist.ts6
-rw-r--r--server/models/video/video.ts4
10 files changed, 31 insertions, 24 deletions
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
124 executeIfActivityPub(asyncMiddleware(videoFileRedundancyGetValidator)), 124 executeIfActivityPub(asyncMiddleware(videoFileRedundancyGetValidator)),
125 executeIfActivityPub(asyncMiddleware(videoRedundancyController)) 125 executeIfActivityPub(asyncMiddleware(videoRedundancyController))
126) 126)
127activityPubClientRouter.get('/redundancy/video-playlists/:streamingPlaylistType/:videoId', 127activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId',
128 executeIfActivityPub(asyncMiddleware(videoPlaylistRedundancyGetValidator)), 128 executeIfActivityPub(asyncMiddleware(videoPlaylistRedundancyGetValidator)),
129 executeIfActivityPub(asyncMiddleware(videoRedundancyController)) 129 executeIfActivityPub(asyncMiddleware(videoRedundancyController))
130) 130)
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 @@
1import * as cors from 'cors' 1import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import { CONFIG, HLS_PLAYLIST_DIRECTORY, ROUTE_CACHE_LIFETIME, STATIC_DOWNLOAD_PATHS, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers' 3import {
4 CONFIG,
5 HLS_STREAMING_PLAYLIST_DIRECTORY,
6 ROUTE_CACHE_LIFETIME,
7 STATIC_DOWNLOAD_PATHS,
8 STATIC_MAX_AGE,
9 STATIC_PATHS
10} from '../initializers'
4import { VideosPreviewCache } from '../lib/cache' 11import { VideosPreviewCache } from '../lib/cache'
5import { cacheRoute } from '../middlewares/cache' 12import { cacheRoute } from '../middlewares/cache'
6import { asyncMiddleware, videosGetValidator } from '../middlewares' 13import { asyncMiddleware, videosGetValidator } from '../middlewares'
@@ -53,9 +60,9 @@ staticRouter.use(
53 60
54// HLS 61// HLS
55staticRouter.use( 62staticRouter.use(
56 STATIC_PATHS.PLAYLISTS.HLS, 63 STATIC_PATHS.STREAMING_PLAYLISTS.HLS,
57 cors(), 64 cors(),
58 express.static(HLS_PLAYLIST_DIRECTORY, { fallthrough: false }) // 404 if the file does not exist 65 express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }) // 404 if the file does not exist
59) 66)
60 67
61// Thumbnails path for express 68// 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 () {
12 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', 12 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max',
13 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', 13 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address',
14 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 14 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache',
15 'storage.redundancy', 'storage.tmp', 'storage.playlists', 15 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists',
16 'log.level', 16 'log.level',
17 'user.video_quota', 'user.video_quota_daily', 17 'user.video_quota', 'user.video_quota_daily',
18 'csp.enabled', 'csp.report_only', 'csp.report_uri', 18 '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 = {
196 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), 196 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
197 LOG_DIR: buildPath(config.get<string>('storage.logs')), 197 LOG_DIR: buildPath(config.get<string>('storage.logs')),
198 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), 198 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
199 PLAYLISTS_DIR: buildPath(config.get<string>('storage.playlists')), 199 STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')),
200 REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')), 200 REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
201 THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), 201 THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
202 PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), 202 PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
@@ -625,8 +625,8 @@ const STATIC_PATHS = {
625 TORRENTS: '/static/torrents/', 625 TORRENTS: '/static/torrents/',
626 WEBSEED: '/static/webseed/', 626 WEBSEED: '/static/webseed/',
627 REDUNDANCY: '/static/redundancy/', 627 REDUNDANCY: '/static/redundancy/',
628 PLAYLISTS: { 628 STREAMING_PLAYLISTS: {
629 HLS: '/static/playlists/hls' 629 HLS: '/static/streaming-playlists/hls'
630 }, 630 },
631 AVATARS: '/static/avatars/', 631 AVATARS: '/static/avatars/',
632 VIDEO_CAPTIONS: '/static/video-captions/' 632 VIDEO_CAPTIONS: '/static/video-captions/'
@@ -670,7 +670,7 @@ const CACHE = {
670 } 670 }
671} 671}
672 672
673const HLS_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.PLAYLISTS_DIR, 'hls') 673const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls')
674const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') 674const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
675 675
676const MEMOIZE_TTL = { 676const MEMOIZE_TTL = {
@@ -777,7 +777,7 @@ export {
777 PRIVATE_RSA_KEY_SIZE, 777 PRIVATE_RSA_KEY_SIZE,
778 ROUTE_CACHE_LIFETIME, 778 ROUTE_CACHE_LIFETIME,
779 SORTABLE_COLUMNS, 779 SORTABLE_COLUMNS,
780 HLS_PLAYLIST_DIRECTORY, 780 HLS_STREAMING_PLAYLIST_DIRECTORY,
781 FEEDS, 781 FEEDS,
782 JOB_TTL, 782 JOB_TTL,
783 NSFW_POLICY_TYPES, 783 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'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { applicationExist, clientsExist, usersExist } from './checker-after-init' 8import { applicationExist, clientsExist, usersExist } from './checker-after-init'
9import { CACHE, CONFIG, HLS_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' 9import { CACHE, CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants'
10import { sequelizeTypescript } from './database' 10import { sequelizeTypescript } from './database'
11import { remove, ensureDir } from 'fs-extra' 11import { remove, ensureDir } from 'fs-extra'
12 12
@@ -74,7 +74,7 @@ function createDirectoriesIfNotExist () {
74 } 74 }
75 75
76 // Playlist directories 76 // Playlist directories
77 tasks.push(ensureDir(HLS_PLAYLIST_DIRECTORY)) 77 tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY))
78 78
79 return Promise.all(tasks) 79 return Promise.all(tasks)
80} 80}
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) {
27} 27}
28 28
29function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { 29function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
30 return `${CONFIG.WEBSERVER.URL}/redundancy/video-playlists/${playlist.getStringType()}/${video.uuid}` 30 return `${CONFIG.WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
31} 31}
32 32
33function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { 33function 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 @@
1import { VideoModel } from '../models/video/video' 1import { VideoModel } from '../models/video/video'
2import { basename, join, dirname } from 'path' 2import { basename, join, dirname } from 'path'
3import { CONFIG, HLS_PLAYLIST_DIRECTORY } from '../initializers' 3import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY } from '../initializers'
4import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' 4import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra'
5import { getVideoFileSize } from '../helpers/ffmpeg-utils' 5import { getVideoFileSize } from '../helpers/ffmpeg-utils'
6import { sha256 } from '../helpers/core-utils' 6import { sha256 } from '../helpers/core-utils'
@@ -11,7 +11,7 @@ import { generateRandomString } from '../helpers/utils'
11import { flatten, uniq } from 'lodash' 11import { flatten, uniq } from 'lodash'
12 12
13async function updateMasterHLSPlaylist (video: VideoModel) { 13async function updateMasterHLSPlaylist (video: VideoModel) {
14 const directory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) 14 const directory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
15 const masterPlaylists: string[] = [ '#EXTM3U', '#EXT-X-VERSION:3' ] 15 const masterPlaylists: string[] = [ '#EXTM3U', '#EXT-X-VERSION:3' ]
16 const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename()) 16 const masterPlaylistPath = join(directory, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename())
17 17
@@ -40,7 +40,7 @@ async function updateMasterHLSPlaylist (video: VideoModel) {
40async function updateSha256Segments (video: VideoModel) { 40async function updateSha256Segments (video: VideoModel) {
41 const json: { [filename: string]: { [range: string]: string } } = {} 41 const json: { [filename: string]: { [range: string]: string } } = {}
42 42
43 const playlistDirectory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) 43 const playlistDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
44 44
45 // For all the resolutions available for this video 45 // For all the resolutions available for this video
46 for (const file of video.VideoFiles) { 46 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 @@
1import { CONFIG, HLS_PLAYLIST_DIRECTORY } from '../initializers' 1import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY } from '../initializers'
2import { extname, join } from 'path' 2import { extname, join } from 'path'
3import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' 3import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils'
4import { copy, ensureDir, move, remove, stat } from 'fs-extra' 4import { copy, ensureDir, move, remove, stat } from 'fs-extra'
@@ -89,8 +89,8 @@ async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoR
89} 89}
90 90
91async function generateHlsPlaylist (video: VideoModel, resolution: VideoResolution, isPortraitMode: boolean) { 91async function generateHlsPlaylist (video: VideoModel, resolution: VideoResolution, isPortraitMode: boolean) {
92 const baseHlsDirectory = join(HLS_PLAYLIST_DIRECTORY, video.uuid) 92 const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
93 await ensureDir(join(HLS_PLAYLIST_DIRECTORY, video.uuid)) 93 await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid))
94 94
95 const videoInputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(video.getOriginalFile())) 95 const videoInputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(video.getOriginalFile()))
96 const outputPath = join(baseHlsDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) 96 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<VideoStreamingPlaylistMod
130 } 130 }
131 131
132 static getHlsMasterPlaylistStaticPath (videoUUID: string) { 132 static getHlsMasterPlaylistStaticPath (videoUUID: string) {
133 return join(STATIC_PATHS.PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename()) 133 return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getMasterHlsPlaylistFilename())
134 } 134 }
135 135
136 static getHlsPlaylistStaticPath (videoUUID: string, resolution: number) { 136 static getHlsPlaylistStaticPath (videoUUID: string, resolution: number) {
137 return join(STATIC_PATHS.PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) 137 return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution))
138 } 138 }
139 139
140 static getHlsSha256SegmentsStaticPath (videoUUID: string) { 140 static getHlsSha256SegmentsStaticPath (videoUUID: string) {
141 return join(STATIC_PATHS.PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsSha256SegmentsFilename()) 141 return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, VideoStreamingPlaylistModel.getHlsSha256SegmentsFilename())
142 } 142 }
143 143
144 getStringType () { 144 getStringType () {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index a563f78ef..06c63e87c 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -53,7 +53,7 @@ import {
53 API_VERSION, 53 API_VERSION,
54 CONFIG, 54 CONFIG,
55 CONSTRAINTS_FIELDS, 55 CONSTRAINTS_FIELDS,
56 HLS_PLAYLIST_DIRECTORY, 56 HLS_STREAMING_PLAYLIST_DIRECTORY,
57 HLS_REDUNDANCY_DIRECTORY, 57 HLS_REDUNDANCY_DIRECTORY,
58 PREVIEWS_SIZE, 58 PREVIEWS_SIZE,
59 REMOTE_SCHEME, 59 REMOTE_SCHEME,
@@ -1751,7 +1751,7 @@ export class VideoModel extends Model<VideoModel> {
1751 } 1751 }
1752 1752
1753 removeStreamingPlaylist (isRedundancy = false) { 1753 removeStreamingPlaylist (isRedundancy = false) {
1754 const baseDir = isRedundancy ? HLS_REDUNDANCY_DIRECTORY : HLS_PLAYLIST_DIRECTORY 1754 const baseDir = isRedundancy ? HLS_REDUNDANCY_DIRECTORY : HLS_STREAMING_PLAYLIST_DIRECTORY
1755 1755
1756 const filePath = join(baseDir, this.uuid) 1756 const filePath = join(baseDir, this.uuid)
1757 return remove(filePath) 1757 return remove(filePath)