]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/live/live-utils.ts
Cleanup muxing session method options
[github/Chocobozzz/PeerTube.git] / server / lib / live / live-utils.ts
CommitLineData
8ebf2a5d
C
1import { remove } from 'fs-extra'
2import { basename } from 'path'
3import { MStreamingPlaylist, MVideo } from '@server/types/models'
0305db28 4import { getLiveDirectory } from '../paths'
8ebf2a5d
C
5
6function buildConcatenatedName (segmentOrPlaylistPath: string) {
7 const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/)
8
9 return 'concat-' + num[1] + '.ts'
10}
11
4ec52d04 12async function cleanupLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) {
0305db28 13 const hlsDirectory = getLiveDirectory(video)
8ebf2a5d
C
14
15 await remove(hlsDirectory)
16
4ec52d04 17 if (streamingPlaylist) await streamingPlaylist.destroy()
8ebf2a5d
C
18}
19
20export {
21 cleanupLive,
22 buildConcatenatedName
23}