diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-23 11:20:00 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-07-26 11:29:31 +0200 |
commit | 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (patch) | |
tree | 198ca5f242c63a205a05fa4cfd6d063277c541fd /shared/extra-utils/miscs | |
parent | 83903cb65d531a6b6b91715387493ba8312b264d (diff) | |
download | PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.gz PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.zst PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.zip |
Use random names for VOD HLS playlists
Diffstat (limited to 'shared/extra-utils/miscs')
-rw-r--r-- | shared/extra-utils/miscs/webtorrent.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts index 815ea3d56..a1097effe 100644 --- a/shared/extra-utils/miscs/webtorrent.ts +++ b/shared/extra-utils/miscs/webtorrent.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { readFile } from 'fs-extra' | 1 | import { readFile } from 'fs-extra' |
2 | import * as parseTorrent from 'parse-torrent' | 2 | import * as parseTorrent from 'parse-torrent' |
3 | import { join } from 'path' | 3 | import { basename, join } from 'path' |
4 | import * as WebTorrent from 'webtorrent' | 4 | import * as WebTorrent from 'webtorrent' |
5 | import { VideoFile } from '@shared/models' | ||
5 | import { PeerTubeServer } from '../server' | 6 | import { PeerTubeServer } from '../server' |
6 | 7 | ||
7 | let webtorrent: WebTorrent.Instance | 8 | let webtorrent: WebTorrent.Instance |
@@ -15,8 +16,8 @@ function webtorrentAdd (torrent: string, refreshWebTorrent = false) { | |||
15 | return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res)) | 16 | return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res)) |
16 | } | 17 | } |
17 | 18 | ||
18 | async function parseTorrentVideo (server: PeerTubeServer, videoUUID: string, resolution: number) { | 19 | async function parseTorrentVideo (server: PeerTubeServer, file: VideoFile) { |
19 | const torrentName = videoUUID + '-' + resolution + '.torrent' | 20 | const torrentName = basename(file.torrentUrl) |
20 | const torrentPath = server.servers.buildDirectory(join('torrents', torrentName)) | 21 | const torrentPath = server.servers.buildDirectory(join('torrents', torrentName)) |
21 | 22 | ||
22 | const data = await readFile(torrentPath) | 23 | const data = await readFile(torrentPath) |