]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/live/live-utils.ts
Add support for saving video files to object storage (#4290)
[github/Chocobozzz/PeerTube.git] / server / lib / live / live-utils.ts
1 import { remove } from 'fs-extra'
2 import { basename } from 'path'
3 import { MStreamingPlaylist, MVideo } from '@server/types/models'
4 import { getLiveDirectory } from '../paths'
5
6 function buildConcatenatedName (segmentOrPlaylistPath: string) {
7 const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/)
8
9 return 'concat-' + num[1] + '.ts'
10 }
11
12 async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
13 const hlsDirectory = getLiveDirectory(video)
14
15 await remove(hlsDirectory)
16
17 await streamingPlaylist.destroy()
18 }
19
20 export {
21 cleanupLive,
22 buildConcatenatedName
23 }