From edf1323e85b4a84385f92102394ff82a4046b6f3 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Mon, 21 Apr 2014 12:01:48 +0300 Subject: [PATCH] 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. --- social/kickass/99-kickass.html | 24 +++++++++++++----------- social/kickass/99-kickass.js | 22 +++++----------------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/social/kickass/99-kickass.html b/social/kickass/99-kickass.html index cc581c3e..68641ca5 100644 --- a/social/kickass/99-kickass.html +++ b/social/kickass/99-kickass.html @@ -49,18 +49,20 @@
 {
    "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
 }
 

diff --git a/social/kickass/99-kickass.js b/social/kickass/99-kickass.js index 597659ed..5bca6ebd 100644 --- a/social/kickass/99-kickass.js +++ b/social/kickass/99-kickass.js @@ -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); } }); });