torrent-to-magnet
Advanced tools
Comparing version 1.0.0 to 1.0.1
#!/usr/bin/env node | ||
var readTorrent = require('./index.js'); | ||
if (!process.argv[2]) { | ||
console.error('usage: torrent-to-magnet url'); | ||
console.error('Usage: torrent-to-magnet url'); | ||
process.exit(1); | ||
@@ -6,0 +7,0 @@ } |
33
index.js
@@ -20,2 +20,15 @@ var request = require('request'); | ||
var onData = function(err, data) { | ||
if (err) { | ||
return asyncCallback(err); | ||
} | ||
try { | ||
var result = parseTorrent(data); | ||
var uri = parseTorrent.toMagnetURI(result); | ||
} catch (err) { | ||
return asyncCallback(err); | ||
} | ||
asyncCallback(err, uri); | ||
}; | ||
var onResponse = function(err, response) { | ||
@@ -34,19 +47,9 @@ if (err) { | ||
var onData = function(err, data) { | ||
if (err) { | ||
return asyncCallback(err); | ||
} | ||
try { | ||
var result = parseTorrent(data); | ||
var uri = parseTorrent.toMagnetURI(result); | ||
} catch (err) { | ||
return asyncCallback(err); | ||
} | ||
asyncCallback(err, uri); | ||
}; | ||
if (/^http?:/.test(url)) { | ||
return request(extend({ url: url, encoding: null }, options), onResponse); | ||
} | ||
var httpRegex = new RegExp(/^https?:/); | ||
if (httpRegex.test(url)) { | ||
return request(extend({ url: url, encoding: null }, options), onResponse); | ||
} | ||
}; |
{ | ||
"name": "torrent-to-magnet", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Generate magnet-uri from torrent file", | ||
"repository": "git://github.com/apsdehal/torrent-to-magnet.git", | ||
"dependencies": { | ||
"parse-torrent": "~1.0.0", | ||
"extend": "^3.0.0", | ||
"parse-torrent": "^5.3.0", | ||
"request": "~2.16.2" | ||
@@ -12,3 +13,10 @@ }, | ||
"torrent-to-magnet": "./cli.js" | ||
}, | ||
"devDependencies": { | ||
"chai": "^2.2.0", | ||
"mocha": "~2.2.1" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha -u bdd test.js" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4229
8
72
3
2
+ Addedextend@^3.0.0
+ Addedbencode@2.0.3(transitive)
+ Addedbep53-range@1.1.1(transitive)
+ Addedblob-to-buffer@1.2.9(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedget-stdin@6.0.0(transitive)
+ Addedmagnet-uri@5.4.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedparse-torrent@5.9.1(transitive)
+ Addedrusha@0.8.14(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@2.8.2(transitive)
+ Addedsimple-sha1@2.1.2(transitive)
+ Addedthirty-two@1.0.2(transitive)
+ Addeduniq@1.0.1(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedbncode@0.5.3(transitive)
- Removedparse-torrent@1.0.0(transitive)
- Removedrusha-browserify@0.7.3(transitive)
Updatedparse-torrent@^5.3.0