From 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 23 Jul 2021 11:20:00 +0200 Subject: Use random names for VOD HLS playlists --- shared/extra-utils/miscs/webtorrent.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'shared/extra-utils/miscs') 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 @@ import { readFile } from 'fs-extra' import * as parseTorrent from 'parse-torrent' -import { join } from 'path' +import { basename, join } from 'path' import * as WebTorrent from 'webtorrent' +import { VideoFile } from '@shared/models' import { PeerTubeServer } from '../server' let webtorrent: WebTorrent.Instance @@ -15,8 +16,8 @@ function webtorrentAdd (torrent: string, refreshWebTorrent = false) { return new Promise(res => webtorrent.add(torrent, res)) } -async function parseTorrentVideo (server: PeerTubeServer, videoUUID: string, resolution: number) { - const torrentName = videoUUID + '-' + resolution + '.torrent' +async function parseTorrentVideo (server: PeerTubeServer, file: VideoFile) { + const torrentName = basename(file.torrentUrl) const torrentPath = server.servers.buildDirectory(join('torrents', torrentName)) const data = await readFile(torrentPath) -- cgit v1.2.3