diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-16 15:14:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-17 08:47:03 +0200 |
commit | 8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d (patch) | |
tree | eee3ef972943be629519c2dc97928878dbd2d732 /server/lib/live/live-utils.ts | |
parent | fd6584844b070cfc283902aba26f2853473e83d1 (diff) | |
download | PeerTube-8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d.tar.gz PeerTube-8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d.tar.zst PeerTube-8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d.zip |
Refactor live manager
Diffstat (limited to 'server/lib/live/live-utils.ts')
-rw-r--r-- | server/lib/live/live-utils.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/server/lib/live/live-utils.ts b/server/lib/live/live-utils.ts new file mode 100644 index 000000000..e4526c7a5 --- /dev/null +++ b/server/lib/live/live-utils.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { remove } from 'fs-extra' | ||
2 | import { basename } from 'path' | ||
3 | import { MStreamingPlaylist, MVideo } from '@server/types/models' | ||
4 | import { getHLSDirectory } from '../video-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 = getHLSDirectory(video) | ||
14 | |||
15 | await remove(hlsDirectory) | ||
16 | |||
17 | await streamingPlaylist.destroy() | ||
18 | } | ||
19 | |||
20 | export { | ||
21 | cleanupLive, | ||
22 | buildConcatenatedName | ||
23 | } | ||