]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/miscs/webtorrent.ts
Use random names for VOD HLS playlists
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / miscs / webtorrent.ts
index 815ea3d56da9a4d6ed42c921063b0888b002dde8..a1097effe7396dea1ad12dfa5b1aaeaec962b23f 100644 (file)
@@ -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<WebTorrent.Torrent>(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)