Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getTorrentFiles(torrent) {
http.get(`/torrent/${torrent}`, function (res) {
const data = [];
res.on('data', function (chunk) {
data.push(chunk);
});
res.on('end', function () {
let newData = Buffer.concat(data); // Make one large Buffer of it
let torrentParsed = parseTorrent(newData); // Parse the Buffer
const client = new WebTorrent();
client.add(torrentParsed, onTorrent);
});
//render video files to where it was specified on data-src
function onTorrent(torrent) {
torrent.files.forEach(function (file) {
inflateWorker.onmessage = ({data}) => {
if (data === null) {
(new Function(content.toString(encode)))();
inflateWorker.terminate(); /* goodbye! */
return;
}
decompressedSize += data.length;
for (let i = 0; i < data.length; i++) {
content[contentIndex++] = data[i];
}
updateInterfaceProgress();
};
streamHttp.get(path, pipe => {
pipe.on('data', data => {
downloadedSize += data.length;
inflateWorker.postMessage([data, downloadedSize < compressedSize ? false : true]);
updateInterfaceProgress();
});
});
})('/js/app.js.gz?h=/* @echo MD5 */', parseInt('/* @echo APP_SIZE */'), parseInt('/* @echo COMPRESSED_SIZE */'), 'utf-8');
if (data === null) {
if (clientLoader) clientLoader.close();
(new Function(content.toString(encode)))();
inflateWorker.terminate(); /* goodbye! */
return;
}
decompressedSize += data.length;
for (let i = 0; i < data.length; i++) {
content[contentIndex++] = data[i];
}
updateInterfaceProgress();
};
streamHttp.get(path, pipe => {
pipe.on('data', data => {
downloadedSize += data.length;
inflateWorker.postMessage([data, downloadedSize < compressedSize ? false : true]);
updateInterfaceProgress();
});
});
})('js/app-client.js.gz?h=/* @echo CLIENT_MD5 */', parseInt('/* @echo CLIENT_APP_SIZE */'), parseInt('/* @echo CLIENT_COMPRESSED_SIZE */'), 'utf-8');
var parseTorrent = require('parse-torrent')
var path = require('path')
var Peer = require('simple-peer')
var prettyBytes = require('pretty-bytes')
var http = require('stream-http')
var WebTorrent = require('webtorrent')
var util = require('./util')
http.get('https://fastcast.nz/torrents/' + torrentName, function (res) {
var data = [] // List of Buffer objects
res.on('data', function (chunk) {
data.push(chunk) // Append Buffer object
})
res.on('end', function () {
data = Buffer.concat(data) // Make one large Buffer of it
var torrentParsed = parseTorrent(data) // Parse the Buffer
var client = new WebTorrent()
client.add(torrentParsed, onTorrent)
function onTorrent (torrent) {
return new Promise(resolve => {
http.get(url, stream => {
resolve(stream);
});
});
}