X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fmiscs%2Fwebtorrent.ts;h=a1097effe7396dea1ad12dfa5b1aaeaec962b23f;hb=764b1a14fc494f2cfd7ea590d2f07b01df65c7ad;hp=84e390b2ac587ff9b982f093755cb16010d80b3e;hpb=89d241a79c262b9775c233b73cff080043ebb5e6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts index 84e390b2a..a1097effe 100644 --- a/shared/extra-utils/miscs/webtorrent.ts +++ b/shared/extra-utils/miscs/webtorrent.ts @@ -1,8 +1,9 @@ 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 { ServerInfo } from '../server' +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: ServerInfo, 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)