diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 09:43:59 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 6c5065a011b099618681a37bd77eaa7bd3db752e (patch) | |
tree | 352252a00b25013c4b1902f6bcd9668aba295c7b /shared/extra-utils/miscs/webtorrent.ts | |
parent | 0d8ecb7592577f54012413a2b5a9b159cfc90399 (diff) | |
download | PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.gz PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.zst PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.zip |
Introduce server commands
Diffstat (limited to 'shared/extra-utils/miscs/webtorrent.ts')
-rw-r--r-- | shared/extra-utils/miscs/webtorrent.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts new file mode 100644 index 000000000..82548946d --- /dev/null +++ b/shared/extra-utils/miscs/webtorrent.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | import * as WebTorrent from 'webtorrent' | ||
2 | |||
3 | let webtorrent: WebTorrent.Instance | ||
4 | |||
5 | function 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 | |||
14 | export { | ||
15 | webtorrentAdd | ||
16 | } | ||