Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pause/resume, refactored code, improved command line interface, etc #514

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

fixed cli for search

  • Loading branch information
whitef0x0 committed Nov 27, 2015
commit 9f4768f22abc77b2a0c997dd9dda5c2142736720
@@ -174,6 +174,7 @@ Example:
webtorrent download "magnet:..." --vlc
Commands:
search <search-query> Search for a torrent on kat.cr
download <torrent-id> Download a torrent
seed <file/folder> Seed a file or folder
create <file> Create a .torrent file
@@ -481,14 +482,18 @@ function runSearch (input_query) {
clivas.line('{green: '+process.argv[0] + ' ' + pathToBin + ' "query"'+'}')
};
}else{
process.stdout.write(new Buffer('G1tIG1sySg==', 'base64')) // clear for drawing
clivas.line('Searching for {green:\''+input_query+'\'}...')
search(input_query).then(function(search_results) {
choices('Select your torrent (by index)', search_results.slice(0, 9).filter(function(r){ if(r.torrent || r.magnet) return }).map(function(r) { return r.name + ' [' + r.size + ' / ' + r.files + ' files] ' + r.seeds + '/' + r.leech; }), function(index) {
clivas.clear()
clivas.line('\n{bold: Search Results for {green: \''+input_query+'\' } }\n')
choices('Select your torrent (by number)', search_results.slice(0, 9).filter(function(r){ if(r.torrent || r.magnet){ return true } else { return false } }).map(function(r) { return r.name + ' [' + r.size + ' / ' + r.files + ' files] ' + r.seeds + '/' + r.leech }), function(index) {
if (index === null) {
return
}

console.log(search_results[index])
//console.log(search_results[index])
if(/^magnet:/.test(search_results[index].magnet)) {
clivas.clear()
runDownload(search_results[index].magnet)
}else {
return
@@ -544,16 +549,16 @@ function drawTorrent (torrent) {
type: 'input',
name: 'shouldQuit',
validate: function(input) {
if (input === 'y' || input === 'n') {
if (input === 'Y' || input === 'y' || input === 'N' || input === 'n') {
// Pass the return value in the done callback
return true
}else{
return "Incorrect input. Please enter 'y' or 'n'"
return "Incorrect input. Please enter 'Y' or 'n'"
}
},
filter: function( input ) {
if(input === 'y') return true
else if(input === 'n') return false
if(input === 'Y' || input === 'y') return true
else if(input === 'N' || input === 'n') return false
},
message: 'Do you wish to quit? (Y/n)',
}], function (answers) {
@@ -1,6 +1,6 @@
module.exports = WebTorrent

var search = require('kat-search.ph')
var search = require('search-kat.ph')
var createTorrent = require('create-torrent')
var debug = require('debug')('webtorrent')
var DHT = require('bittorrent-dht/client') // browser exclude
@@ -122,7 +122,7 @@ WebTorrent.prototype.getBySearch = function (query) {
search(query).then(function(search_results) {
search_results = search_results.slice(0, 9).filter(function(r){ if(r.torrent || r.magnet) return })
return self.get(search_results[0].magnet)
}
})
}

/**
@@ -218,7 +218,7 @@ Torrent.prototype._onParsedTorrent = function (parsedTorrent) {
self.swarm.on('wire', self._onWire.bind(self))

self.swarm.on('download', function (downloaded) {
console.log('swarm.on(download): '+self.progress)
//console.log('swarm.on(download): '+self.progress)
self.client.downloadSpeed(downloaded) // update overall client stats
self.client.emit('download', downloaded)
self.emit('download', downloaded)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.