1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Using node-kickass-json instead of node-kickass

The major difference is the use of the JSON API of Kickass instead of parsing the XML file of the search.
This commit is contained in:
Antoine Aflalo 2014-04-21 12:01:48 +03:00
parent 3c393c472c
commit edf1323e85
2 changed files with 18 additions and 28 deletions

View File

@ -49,18 +49,20 @@
<pre> <pre>
{ {
"title":"Ubuntu 14.04 LTS Trusty Tahr desktop 32bit ISO", "title":"Ubuntu 14.04 LTS Trusty Tahr desktop 32bit ISO",
"description":"Ubuntu 14.04", "category":"Applications",
"date":"2014-04-17T18:22:07.000Z",
"link":"http://kickass.to/ubuntu-14-04-lts-trusty-tahr-desktop-32bit-iso-t9007070.html", "link":"http://kickass.to/ubuntu-14-04-lts-trusty-tahr-desktop-32bit-iso-t9007070.html",
"categories":[ "guid":"http://kickass.to/ubuntu-14-04-lts-trusty-tahr-desktop-32bit-iso-t9007070.html",
"Applications - UNIX" "pubDate":"Thursday 17 Apr 2014 18:22:07 +0000",
], "torrentLink":"http://torcache.net/torrent/7A1073BC39E6B0B01E3730227B8FFEA6AEAC5D59.torrent?title=[kickass.to]ubuntu.14.04.lts.trusty.tahr.desktop.32bit.iso",
"torrentFileInfo":{ "files":1,
"url":"http://torcache.net/torrent/7A1073BC39E6B0B01E3730227B8FFEA6AEAC5D59.torrent?title=[kickass.to]ubuntu.14.04.lts.trusty.tahr.desktop.32bit.iso", "comments":0,
"type":"application/x-bittorrent", "hash":"7A1073BC39E6B0B01E3730227B8FFEA6AEAC5D59",
"length":"1017118720" "peers":2394,
}, "seeds":2092,
"torrentMagnet":"magnet:?xt=urn:btih:7A1073BC39E6B0B01E3730227B8FFEA6AEAC5D59&dn=ubuntu+14+04+lts+trusty+tahr+desktop+32bit+iso&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce" "leechs":302,
"size":1017118720,
"votes":2,
"verified":0
} }
</pre></p> </pre></p>

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
**/ **/
var RED = require(process.env.NODE_RED_HOME + "/red/red"); var RED = require(process.env.NODE_RED_HOME + "/red/red");
var Kickass = require('node-kickass'); var Kickass = require('node-kickass-json');
function KickassNode(n) { function KickassNode(n) {
@ -31,24 +31,12 @@ function KickassNode(n) {
this.on("input", function (msg) { this.on("input", function (msg) {
var query = msg.topic || this.title; var query = msg.topic || this.title;
msg.topic = query; msg.topic = query;
msg.payload = []; this.kickass.setQuery(query).run(function (error, data) {
this.kickass.setQuery(query).run(function (errors, data) { if (error === null) {
if (!errors.length > 0) { msg.payload = data;
data.forEach(function (torrent) {
var parsedTorrent = {};
parsedTorrent.title = torrent.title;
parsedTorrent.description = torrent.description;
parsedTorrent.date = torrent.date;
parsedTorrent.link = torrent.link;
parsedTorrent.categories = torrent.categories;
parsedTorrent.torrentFileInfo = torrent.enclosures[0];
parsedTorrent.torrentMagnet = torrent["torrent:magneturi"]["#"];
msg.payload.push(parsedTorrent);
});
node.send(msg); node.send(msg);
} else { } else {
node.send(msg); node.error(error);
} }
}); });
}); });