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 (and more) #515

Closed
wants to merge 31 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
53d6335
got tests for pause/resume to pass
whitef0x0 Nov 27, 2015
cd1d84c
added nice cli for seed quitting interface
whitef0x0 Nov 27, 2015
61d1afb
added resume/pause support for audio/video streaming
whitef0x0 Nov 27, 2015
c68d39d
got gracefulExit to stop hanging
whitef0x0 Nov 27, 2015
67c9c47
added disableSeeding option for torrent
whitef0x0 Nov 27, 2015
01a685a
added getBySearch method
whitef0x0 Nov 27, 2015
b003801
added documentation for getBySearch
whitef0x0 Nov 27, 2015
9f4768f
fixed cli for search
whitef0x0 Nov 27, 2015
9ceac78
added tests for addBySearch()
whitef0x0 Nov 27, 2015
2415418
got all tests to pass but one
whitef0x0 Nov 30, 2015
be0b718
got download /path/to/file cmd.js test to pass
whitef0x0 Dec 1, 2015
b1430c8
updated browser code
whitef0x0 Dec 2, 2015
3db0dad
fixed cmd
whitef0x0 Dec 2, 2015
488bcc9
updated minified build
whitef0x0 Dec 2, 2015
10f9cc2
added unit tests for torrent.js
whitef0x0 Dec 3, 2015
53ea5f1
added tests for appendTo
whitef0x0 Dec 4, 2015
af023ce
added .npmignore
whitef0x0 Dec 4, 2015
74382ee
got zuul tests to run
whitef0x0 Dec 4, 2015
341ed30
removed extraneous user stories
whitef0x0 Dec 4, 2015
428a9ac
added documentation for new methods to the README
whitef0x0 Dec 4, 2015
8752393
added test cli interface
whitef0x0 Dec 5, 2015
2737d3f
updated travis-ci build
whitef0x0 Dec 5, 2015
9067381
started travis-ci
whitef0x0 Dec 5, 2015
254eae0
fixed package.json and travis.yml; got travis-ci to pass
whitef0x0 Dec 5, 2015
7f03f39
added main property to bower.json
whitef0x0 Dec 5, 2015
cb9849c
added ignore to bower.json
whitef0x0 Dec 5, 2015
d82559d
removed search functionality
whitef0x0 Dec 5, 2015
7610325
removed bower
whitef0x0 Dec 5, 2015
4d44ccd
Create description.md
whitef0x0 Dec 11, 2015
9f56b0c
Update test.js
whitef0x0 Dec 11, 2015
82fffad
Added description of changes
whitef0x0 Dec 11, 2015
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

removed search functionality

  • Loading branch information
whitef0x0 committed Dec 5, 2015
commit d82559dfda1c7b7a20ed36578cc19e507db8b745
@@ -1,6 +1,5 @@
#!/usr/bin/env node

var search = require('search-kat.ph')
var choices = require('choices')
var clivas = require('clivas')
var cp = require('child_process')
@@ -145,8 +144,6 @@ if (command === 'help' || argv.help) {
runDownload(/* torrentId */ argv._[1])
} else if (command === 'seed') {
runSeed(/* input */ argv._[1])
} else if (command === 'search') {
runSearch(/* query */ argv._[1])
} else if (command) {
// assume command is "download" when not specified
runDownload(/* torrentId */ command)
@@ -175,7 +172,6 @@ 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
@@ -468,49 +464,6 @@ function runDownload (torrentId) {
}
}

function runSearch (input_query) {
if (!input_query) {
(function showUsage () {
var pathToBin = path.join(
path.relative(
process.cwd(),
path.dirname(process.argv[1])
),
path.basename(process.argv[1])
)

clivas.line('{green:Usage: }')
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) {
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 }
return false
})
.map(function (r) {
return r.name + ' [' + r.size + ' / ' + r.files + ' files] ' + r.seeds + '/' + r.leech
}),
function (index) {
if (index === null) {
return
}
if (/^magnet:/.test(search_results[index].magnet)) {
clivas.clear()
runDownload(search_results[index].magnet)
} else {
return
}
})
})
}
}

function runSeed (input) {
if (path.extname(input).toLowerCase() === '.torrent' || /^magnet:/.test(input)) {
// `webtorrent seed` is meant for creating a new torrent based on a file or folder
@@ -117,33 +117,6 @@ Object.defineProperty(WebTorrent.prototype, 'ratio', {
}
})

/**
* Searchs by query and downloads the first torrent that most closely matches with `query`.
*
* @param {string} query
* @return {Torrent|null}
*/
WebTorrent.prototype.addBySearch = function (query) {
var self = this
if (!query || typeof query !== 'string') return self.emit('error', new Error('query is invalid'))
if (self.destroyed) return self.emit('error', new Error('client is destroyed'))

searchForTorrents(query).then(function (search_results) {
if (!search_results) return self.emit('error', new Error('could not find any matching torrents'))

var queryTorrent = search_results.filter(
function (r) {
if (r.torrent || r.magnet) return true
return false
}
)[0]
if (!queryTorrent || !queryTorrent.magnet) return self.emit('error', new Error('could not find any valid torrents'))

self.emit('search')
return self.download(queryTorrent.magnet)
})
}

/**
* Returns the torrent with the given `torrentId`. Convenience method. Easier than
* searching through the `client.torrents` array. Returns `null` if no matching torrent
@@ -28,7 +28,6 @@
"bitfield": "^1.0.2",
"bittorrent-dht": "^5.0.0",
"bittorrent-swarm": "^6.0.0",
"choices": "^0.1.3",
"chunk-store-stream": "^2.0.0",
"clivas": "^0.2.0",
"create-torrent": "^3.4.0",
@@ -57,7 +56,6 @@
"range-parser": "^1.0.2",
"re-emitter": "^1.0.0",
"run-parallel": "^1.0.0",
"search-kat.ph": "~1.0.3",
"simple-sha1": "^2.0.0",
"speedometer": "^1.0.0",
"thunky": "^0.1.0",

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.