import * as WebTorrent from 'webtorrent'
import { createWriteStream, ensureDir, remove } from 'fs-extra'
import * as WebTorrent from 'webtorrent'
import { createWriteStream, ensureDir, remove } from 'fs-extra'
import { dirname, join } from 'path'
async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) {
const id = target.magnetUri || target.torrentName
let timer
import { dirname, join } from 'path'
async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) {
const id = target.magnetUri || target.torrentName
let timer
await ensureDir(directoryPath)
return new Promise<string>((res, rej) => {
await ensureDir(directoryPath)
return new Promise<string>((res, rej) => {