mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	Creation of a Kickass Torrent Node
That will query the kickass torrent database and return the torrent with the wanted criterias. Depends on: node-kickass
This commit is contained in:
		
							
								
								
									
										91
									
								
								social/kickass/99-kickass.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								social/kickass/99-kickass.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
			
		||||
<!--
 | 
			
		||||
  Copyright 2013 IBM Corp.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
  http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
-->
 | 
			
		||||
<script type="text/x-red" data-template-name="kickass">
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-title"><i class="icon-tag"></i> Title</label>
 | 
			
		||||
        <input type="text" id="node-input-title" placeholder="Distribution Search">
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-sort"><i class="icon-align-center"></i> Sort</label>
 | 
			
		||||
         <select id="node-input-sort">
 | 
			
		||||
            <option value="time_add">Age</option>
 | 
			
		||||
            <option value="files_count">Files</option>
 | 
			
		||||
            <option value="size">Size</option>
 | 
			
		||||
            <option value="seeders">Seed</option>
 | 
			
		||||
            <option value="leechers">Leech</option>
 | 
			
		||||
        </select>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-order"><i class="icon-circle-arrow-up"></i> Order</label>
 | 
			
		||||
         <select id="node-input-order">
 | 
			
		||||
            <option value="desc">Descending</option>
 | 
			
		||||
            <option value="asc">Ascending</option>
 | 
			
		||||
        </select>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-help-name="kickass">
 | 
			
		||||
<p>This node will query the database of <a target="_blank" href="https://kickass.to">Kickass Torrent</a> and return a list of torrent corresponding to the search.</p>
 | 
			
		||||
    <p>Use the <code>msg.topic</code> as search criteria for KickAss Torrents. If no <code>msg.topic</code> is given, it will use the <code>title</code> of node.</p>
 | 
			
		||||
    <p>The resulting torrents are put into <code>msg.payload</code> as a list of Object.</p>
 | 
			
		||||
    <p>A torrent object will contain these information :
 | 
			
		||||
    <pre>
 | 
			
		||||
{
 | 
			
		||||
   "title":"Ubuntu 14.04 LTS Trusty Tahr desktop 32bit ISO",
 | 
			
		||||
   "description":"Ubuntu 14.04",
 | 
			
		||||
   "date":"2014-04-17T18:22:07.000Z",
 | 
			
		||||
   "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"
 | 
			
		||||
}
 | 
			
		||||
</pre></p>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
    RED.nodes.registerType('kickass', {
 | 
			
		||||
        category: 'social-input',
 | 
			
		||||
        defaults: {
 | 
			
		||||
            title: {value: ""},
 | 
			
		||||
            sort: {value: "", required: true},
 | 
			
		||||
            order: {value: "", required: true}
 | 
			
		||||
        },
 | 
			
		||||
        color: "#F7B457",
 | 
			
		||||
        inputs: 1,
 | 
			
		||||
        outputs: 1,
 | 
			
		||||
        icon: "logo.png",
 | 
			
		||||
        align: "right",
 | 
			
		||||
        label: function () {
 | 
			
		||||
            return this.title || "kickass";
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function () {
 | 
			
		||||
            return this.title ? "node_label_italic" : "";
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
							
								
								
									
										56
									
								
								social/kickass/99-kickass.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								social/kickass/99-kickass.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2013 IBM Corp.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 **/
 | 
			
		||||
var RED = require(process.env.NODE_RED_HOME + "/red/red");
 | 
			
		||||
var Kickass = require('node-kickass');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function KickassNode(n) {
 | 
			
		||||
    RED.nodes.createNode(this, n);
 | 
			
		||||
    this.order = n.order;
 | 
			
		||||
    this.sort = n.sort;
 | 
			
		||||
    this.title = n.title;
 | 
			
		||||
    var node = this;
 | 
			
		||||
    this.kickass = new Kickass();
 | 
			
		||||
    this.kickass.setSort({
 | 
			
		||||
        field: this.sort,
 | 
			
		||||
        sorder: this.order
 | 
			
		||||
    });
 | 
			
		||||
    this.on("input", function (msg) {
 | 
			
		||||
        var query = msg.topic || this.title;
 | 
			
		||||
        this.kickass.setQuery(query).run(function (errors, data) {
 | 
			
		||||
            if (!errors.length > 0) {
 | 
			
		||||
                msg.topic = query;
 | 
			
		||||
                msg.payload = [];
 | 
			
		||||
                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);
 | 
			
		||||
            } else {
 | 
			
		||||
                node.err(errors);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RED.nodes.registerType("kickass", KickassNode);
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								social/kickass/icons/logo.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								social/kickass/icons/logo.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 7.3 KiB  | 
		Reference in New Issue
	
	Block a user