Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).done((data)=>{
this.setState({
data: {
title: data.title,
backdrop: data.backdrop,
tags: data.tags,
rscInfo: data.rsc_info,
introduction: data.introduction
}
})
var infoHash = data.rsc_info.map((r) => {
return r[2].split('magnet:?xt=urn:btih:')[1].split('&')[0]
})
var seeders = new Array(infoHash.length).fill(0)
Tracker.scrape({ announce: this.announce, infoHash: infoHash }, ((err, results) => {
if (err) {
throw err
return
}
if (infoHash.length > 1) {
var i
for (i = 0; i < infoHash.length; i++) {
seeders[i] = results[infoHash[i]].complete
}
} else {
seeders[0] = results.complete
}
this.setState({ seeders: seeders })
}).bind(this))
}).fail(()=>{
console.log("There has an error.")
scrape (hashes) {
const requiredOpts = {
announce: [this.config.tracker],
infoHash: hashes
};
Client.scrape(requiredOpts, (error, results) => {
if (error) {
console.log(error);
setTimeout(() => {
this.run();
}, 5000);
} else {
console.log('Scrape Successful');
this.update(results);
}
});
}
const results = await new Promise((resolve, reject) => {
Client.scrape(options, (error, data) => (error ? reject(error) : resolve(data)));
});