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>
{
"title":"Ubuntu 14.04 LTS Trusty Tahr desktop 32bit ISO",
"description":"Ubuntu 14.04",
"date":"2014-04-17T18:22:07.000Z",
"category":"Applications",
"link":"http://kickass.to/ubuntu-14-04-lts-trusty-tahr-desktop-32bit-iso-t9007070.html",
"categories":[
"Applications - UNIX"
],
"torrentFileInfo":{
"url":"http://torcache.net/torrent/7A1073BC39E6B0B01E3730227B8FFEA6AEAC5D59.torrent?title=[kickass.to]ubuntu.14.04.lts.trusty.tahr.desktop.32bit.iso",
"type":"application/x-bittorrent",
"length":"1017118720"
},
"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"
"guid":"http://kickass.to/ubuntu-14-04-lts-trusty-tahr-desktop-32bit-iso-t9007070.html",
"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",
"files":1,
"comments":0,
"hash":"7A1073BC39E6B0B01E3730227B8FFEA6AEAC5D59",
"peers":2394,
"seeds":2092,
"leechs":302,
"size":1017118720,
"votes":2,
"verified":0
}
</pre></p>

View File

@ -14,7 +14,7 @@
* limitations under the License.
**/
var RED = require(process.env.NODE_RED_HOME + "/red/red");
var Kickass = require('node-kickass');
var Kickass = require('node-kickass-json');
function KickassNode(n) {
@ -31,24 +31,12 @@ function KickassNode(n) {
this.on("input", function (msg) {
var query = msg.topic || this.title;
msg.topic = query;
msg.payload = [];
this.kickass.setQuery(query).run(function (errors, data) {
if (!errors.length > 0) {
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);
});
this.kickass.setQuery(query).run(function (error, data) {
if (error === null) {
msg.payload = data;
node.send(msg);
} else {
node.send(msg);
node.error(error);
}
});
});