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) {
public testPackageJSON(): string {
return require("stream-http/package").version.toString();
}
public testPackageJSON(): string {
return require("stream-http/package").version.toString();
}
return new Promise(resolve => {
http.get(url, stream => {
resolve(stream);
});
});
}
})
return
}
if (opts.help) {
self.postMessage({
event: 'EVAL_OUTPUT_CHUNK',
chunk: encode(help()),
opts,
firstChunk: true,
error: false
})
return
}
evalHttpReq = http.request(
{
method: 'POST',
path: '/eval',
mode: 'prefer-streaming',
headers: {
'Content-Type': 'text/plain',
'Content-Length': Buffer.byteLength(input)
}
},
(res) => {
const onStreamData = (chunk) => {
debug('stream data')
self.postMessage({
event: 'EVAL_OUTPUT_CHUNK',
chunk,
opts,
showLog(logpath, id, logname) {
this.setState({
currentLogName: logname,
logText: [],
});
let path = `/api/operations/showlog/${id}/${logname}`;
let options = {
path,
method: 'GET',
};
let req = http.request(options, (res) => {
this.response = res;
res.on('data', (buf) => {
this.setState({
logText: this.state.logText.concat([buf.toString()]),
});
var objDiv = document.getElementById('logContent');
objDiv.scrollTop = objDiv.scrollHeight;
});
res.on('end', () => {
this.setState({
logText: this.state.logText.concat(['--------------------------------------']),
});
var objDiv = document.getElementById('logContent');
objDiv.scrollTop = objDiv.scrollHeight;
});
});