aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-paths.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video-paths.ts')
-rw-r--r--server/lib/video-paths.ts35
1 files changed, 11 insertions, 24 deletions
diff --git a/server/lib/video-paths.ts b/server/lib/video-paths.ts
index 1708c479a..b7068190c 100644
--- a/server/lib/video-paths.ts
+++ b/server/lib/video-paths.ts
@@ -3,29 +3,20 @@ import { extractVideo } from '@server/helpers/video'
3import { CONFIG } from '@server/initializers/config' 3import { CONFIG } from '@server/initializers/config'
4import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants' 4import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants'
5import { isStreamingPlaylist, MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' 5import { isStreamingPlaylist, MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models'
6import { buildUUID } from '@server/helpers/uuid'
6 7
7// ################## Video file name ################## 8// ################## Video file name ##################
8 9
9function generateVideoFilename (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, isHls: boolean, resolution: number, extname: string) { 10function generateWebTorrentVideoFilename (resolution: number, extname: string) {
10 const video = extractVideo(videoOrPlaylist) 11 const uuid = buildUUID()
11 12
12 // FIXME: use a generated uuid instead, that will break compatibility with PeerTube < 3.1 13 return uuid + '-' + resolution + extname
13 // const uuid = uuidv4()
14 const uuid = video.uuid
15
16 if (isHls) {
17 return generateVideoStreamingPlaylistName(uuid, resolution)
18 }
19
20 return generateWebTorrentVideoName(uuid, resolution, extname)
21} 14}
22 15
23function generateVideoStreamingPlaylistName (uuid: string, resolution: number) { 16function generateHLSVideoFilename (resolution: number) {
24 return `${uuid}-${resolution}-fragmented.mp4` 17 const uuid = buildUUID()
25}
26 18
27function generateWebTorrentVideoName (uuid: string, resolution: number, extname: string) { 19 return `${uuid}-${resolution}-fragmented.mp4`
28 return uuid + '-' + resolution + extname
29} 20}
30 21
31function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) { 22function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) {
@@ -66,12 +57,8 @@ function getHLSDirectory (video: MVideoUUID, isRedundancy = false) {
66// ################## Torrents ################## 57// ################## Torrents ##################
67 58
68function generateTorrentFileName (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, resolution: number) { 59function generateTorrentFileName (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, resolution: number) {
69 const video = extractVideo(videoOrPlaylist)
70 const extension = '.torrent' 60 const extension = '.torrent'
71 61 const uuid = buildUUID()
72 // FIXME: use a generated uuid instead, that will break compatibility with PeerTube < 3.1
73 // const uuid = uuidv4()
74 const uuid = video.uuid
75 62
76 if (isStreamingPlaylist(videoOrPlaylist)) { 63 if (isStreamingPlaylist(videoOrPlaylist)) {
77 return `${uuid}-${resolution}-${videoOrPlaylist.getStringType()}${extension}` 64 return `${uuid}-${resolution}-${videoOrPlaylist.getStringType()}${extension}`
@@ -95,9 +82,9 @@ function getLocalVideoFileMetadataUrl (video: MVideoUUID, videoFile: MVideoFile)
95// --------------------------------------------------------------------------- 82// ---------------------------------------------------------------------------
96 83
97export { 84export {
98 generateVideoStreamingPlaylistName, 85 generateHLSVideoFilename,
99 generateWebTorrentVideoName, 86 generateWebTorrentVideoFilename,
100 generateVideoFilename, 87
101 getVideoFilePath, 88 getVideoFilePath,
102 89
103 generateTorrentFileName, 90 generateTorrentFileName,