Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 'c9dd51027467519d5eb2561ae2cc01467de5f643',
// '0a60bcba24797692efa8770d23df0a830d91cb35',
// 'b3407a88baa0590dc8c9aa6a120f274367dcd867',
// 'e88e8338c572a06e3c801b29f519df532b3e76f6',
// '70cf6aee53107f3d39378483f69cf80fa568b1ea',
// 'c53b506159e988d8bc16922d125d77d803d652c3',
// 'ca3070c16eed9172ab506d20e522ea3f1ab674b3',
// 'f923d76fe8f44ff32e372c3b376564c6fb5f0dbe',
// '52164f03629fd1322636babb2c014b7dae582da4',
// '1363965261e6ce12b43701f0a8c9ed1520a70eba',
// '004400a267765f6d3dd5c7beb5bd3c75f3df2a54',
// '560a61801147fa4ec7cf568e703acb04e5610a4d',
// '56dcc242d03293e9446cf5e457d8eb3d9588fd90',
// 'c698de9b0dad92980906c026d8c1408fa08fe4ec' ] }
const uri = parseTorrent.toMagnetURI({
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
});
const buf = parseTorrent.toTorrentFile({
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
});
parseTorrent.remote('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', (err, parsedTorrent) => {
// if (err) throw err
// console.log(parsedTorrent)
});
if (this.client.tracker && global.WEBTORRENT_ANNOUNCE && !this.private) {
// So `webtorrent-hybrid` can force specific trackers to be used
parsedTorrent.announce = parsedTorrent.announce.concat(global.WEBTORRENT_ANNOUNCE)
}
if (this.urlList) {
// Allow specifying web seeds via `opts` parameter
parsedTorrent.urlList = parsedTorrent.urlList.concat(this.urlList)
}
uniq(parsedTorrent.announce)
uniq(parsedTorrent.urlList)
Object.assign(this, parsedTorrent)
this.magnetURI = parseTorrent.toMagnetURI(parsedTorrent)
this.torrentFile = parseTorrent.toTorrentFile(parsedTorrent)
}
basicTorrentData(torrentUrl, cb)
}
})
} else if (isTorrentString.isTorrentPath(torrent)) {
// local .torrent
let parsed
try {
parsed = parseTorrent(fs.readFileSync(torrent))
} catch (e) { }
if (parsed) {
if (parsed.info && parsed.info.private) {
cb(null, torrent, parsed)
} else {
cb(null, parseTorrent.toMagnetURI(parsed), parsed)
}
} else {
cb(new Error('Could not read torrent file'))
}
} else {
cb(new Error('Unsupported source'))
}
}
parseTorrent.remote(torrentId, function (err, torrentMeta) {
if (err) return cb(err)
if (self.destroyed) return
if (self.get(torrentMeta.infoHash)) return cb(null, self.get(torrentMeta.infoHash))
var rawTorrent = {
magnetURI: parseTorrent.toMagnetURI(torrentMeta),
infoHash: torrentMeta.infoHash,
webseeds: webseeds
}
// if the full meta data exists
if (torrentMeta.info) rawTorrent.torrentMetaBuffer = parseTorrent.toTorrentFile(torrentMeta)
self._torrentStore.add(torrentMeta.infoHash, rawTorrent, function (err) {
if (err) return cb(err)
self._onAdd(rawTorrent, cb)
})
})
createTorrent(file, { announceList: this.announceList }, (err, t) => {
if (err) return console.log(err)
const magnet = parseTorrent.toMagnetURI(parseTorrent(t))
resolve(magnet)
})
})
var load = function(t, callback) {
if(!t)
return callback("Invalid torrent");
if(!t.infoHash)
return callback("Missing hash");
var torrent = findTorrent(t.infoHash);
if(torrent)
return callback("Torrent already exists");
torrent = {
$engine: null,
hash: t.infoHash,
name: t.name,
trackers: t.announce,
magnet: parse.toMagnetURI(t),
files: [],
status: {}
};
list.push(torrent);
torrents.emit("update");
//loaded, now open it
torrents.open({ hash:torrent.hash }, callback);
};
parseTorrent.remote(torrent, (err, parsed) => {
if (parsed && parsed.info && parsed.info.private) {
helpers.downloadFile(torrentUrl || torrent, function(fileLoc) {
cb(err, fileLoc || torrentUrl || torrent, parsed)
}, (parsed.infoHash || Date.now()) + '.torrent', openerDir)
} else {
cb(err, parsed ? parseTorrent.toMagnetURI(parsed) : torrent, parsed)
}
})
} else {
return parseTorrent.remote(link, (err, remote) => {
if (err) {
return reject(err)
}
const magnet = parseTorrent.toMagnetURI(remote)
return webtorrentHealth(magnet).then(health => {
const torrent = type === 'movie'
? this._movieTorrent(magnet, health, remote)
: this._showTorrent(magnet, health)
return resolve(torrent)
})
})
})
fs.writeFile(outf, torrent, function(err) {
if (err) {
reject(err);
return;
}
accept(parseTorrent.toMagnetURI(parseTorrent(torrent)));
});