]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/miscs/webtorrent.ts
Introduce user command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / miscs / webtorrent.ts
CommitLineData
6c5065a0
C
1import * as WebTorrent from 'webtorrent'
2
3let webtorrent: WebTorrent.Instance
4
5function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
6 const WebTorrent = require('webtorrent')
7
8 if (!webtorrent) webtorrent = new WebTorrent()
9 if (refreshWebTorrent === true) webtorrent = new WebTorrent()
10
11 return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res))
12}
13
14export {
15 webtorrentAdd
16}