torrent.on('done', () => { if (!argv.quiet) { const numActiveWires = torrent.wires .reduce((num, wire) => num + (wire.downloaded > 0), 0) clivas.line('') clivas.line( 'torrent downloaded {green:successfully} from {bold:%s/%s} {green:peers} ' + 'in {bold:%ss}!', numActiveWires, torrent.numPeers, getRuntime() ) } torrentDone() })
torrent.on('infoHash', () => { if ('select' in argv) { torrent.so = argv.select.toString() } if (argv.quiet) return updateMetadata() torrent.on('wire', updateMetadata) function updateMetadata () { clivas.clear() clivas.line( '{green:fetching torrent metadata from} {bold:%s} {green:peers}', torrent.numPeers ) } torrent.on('metadata', () => { clivas.clear() torrent.removeListener('wire', updateMetadata) clivas.clear() clivas.line('{green:verifying existing torrent data...}') }) })
torrent.on('download', function (bytes) { let tmpinfo=[] torrent.files.forEach(function(file){
fs.createReadStream(`output/${show.preparedCode}.zip`) .pipe(unzip.Parse()) .on('entry', function (entry) { var fileName = entry.path; if (fileName === subtitleFilename + '.srt') { torrent.on('done', function() { progress.stop() fs.renameSync(`output/${torrent.files[0].name}`, `output/${show.preparedCode}.mkv`) }) torrent.on('download', function (bytes) { progress.update(torrent.progress * 100) })