From bffc966d609524e3f65dcbd7c860cc3c19f6ee67 Mon Sep 17 00:00:00 2001 From: Mark Funston Date: Mon, 2 Apr 2018 20:34:28 +0800 Subject: [PATCH] Version 0.1.0 Update --- LICENSE.md | 15 ++++++++++++ README.md | 60 ++++++++++++++++++++++++++++++++++++++++------- package.json | 23 ++++++++++++------ transmission.html | 56 +++++++++++++++++++++++++++++++++++++++---- transmission.js | 59 +++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 189 insertions(+), 24 deletions(-) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d4f4437 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,15 @@ +# LICENSE + +Copyright 2014, 2015 Andrew D Lindsay @AndrewDLindsay + +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. \ No newline at end of file diff --git a/README.md b/README.md index 7786a53..f5cb6e6 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,58 @@ # node-red-node-transmission -Depends on nodejs package transmission 0.4.2: +A set of Node Red nodes to access the Transmission torrent client remote API -Nodes Defined (2): +## Dependencies -1. Transmission Get Torrents: - * Gets the current torrent list JSON data from the Transmission Instance. - * Returns an Array of the RPC JSON data in msg.payload with a msg.topic of '/transmission.v1/torrentData' - * See the 3.3 Torrent Accessors section of the RPC-Spec (https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt) +Depends on nodejs package transmission v0.4.9: + +## Nodes Defined (3) + +1. Transmission List Torrents: + * Gets the current torrent list JSON data from the Transmission Instance. + * Returns an Array of the RPC JSON data in msg.payload with a msg.topic of '/transmission.v1/torrentData' + * See the 3.3 Torrent Accessors section of the RPC-Spec () 2. Transmission Add Torrent: - * Adds a new torrent via the config panel URL or msg.url value of a .torrent file or a magnet reference. - * Returns a single instance of the RPC JSON data in msg.payload with a msg.topic of '/transmission.v1/torrentAdd' - * See the 3.3 Torrent Accessors section of the RPC-Spec (https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt) + * Adds a new torrent via the config panel URL field or msg.url payload value containing a .torrent file or a magnet URL reference. + * Returns a single instance of the RPC JSON data in msg.payload with a msg.topic of '/transmission.v1/torrentAdd' + * See the 3.3 Torrent Accessors section of the RPC-Spec () + +3. Transmission Remove Torrent: + * Remove a torrent from download queue + * NOTE : This does not trash torrent data i.e. does not remove it from disk + * Remove a torrent via the hashString value of a torrent in Transmission using 'msg.ids'. + * Returns an empty object in msg.payload with a msg.topic of '/transmission.v1/torrentRemove' + * See the 3.3 Torrent Accessors section of the RPC-Spec () + +## To Do + +1. [ ] Add the other Transmission functions from + +## Authors & Contributors + +* **Jay Long** - *Author for the Initial build* - [jlong23](https://github.com/jlong23) +* **Miguel Coquet** - *Corrections & Bugfixes* - [mcoquet](https://github.com/mcoquet) +* **Mark Funston** - *Further Documentation and Enhancements* - [mlfunston](https://github.com/mlfunston) + +## License + +This project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE.md) file for details + +## Changelog + +### v0.1.0 (latest) + +* Updated minor release version +* Added various documentation +* Included code fixes to allow url to be sent to the add torrent function via msg.url +* Moved the nodes to the 'transmission' category +* Added Features: + * Remove Torrent + +### v0.0.1 +* Original release version +* Features: + * List Torrents + * Add Torrent diff --git a/package.json b/package.json index 6579b5f..3d9f39f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "node-red-node-transmission", - "version": "0.0.1", - "description": "A Node-RED node to access Transmission Remote API.", + "version": "0.1.0", + "description": "A Node-RED node to access and control the Transmission torrent client Remote API.", "dependencies": { - "transmission": "0.4.2" + "transmission": "0.4.9" }, "repository": { "type": "git", @@ -12,18 +12,27 @@ "license": "Apache-v2.0", "keywords": [ "node-red", - "transmission" + "transmission", + "torrent" ], "node-red": { "nodes": { "Transmission-API": "transmission.js" } }, + "author": + { + "name": "Jay Long" + }, "contributors": [ { "name": "Jay Long" + }, + { + "name": "Mark Funston", + "email": "mlfunston@gmail.com", + "url": "https://github.com/mlfunston" } - ], - "readme": "node-red-node-transmission\n====================\n\n", - "readmeFilename": "README.md" + ] + } diff --git a/transmission.html b/transmission.html index 3d18696..7212477 100644 --- a/transmission.html +++ b/transmission.html @@ -38,6 +38,10 @@ + + + + + diff --git a/transmission.js b/transmission.js index cce9120..c7959ee 100644 --- a/transmission.js +++ b/transmission.js @@ -93,19 +93,24 @@ module.exports = function(RED) { var node = this; var TransmissionAPI = this.config ? this.config.TransmissionAPI : null; - if (!TransmissionAPI) { + if (!TransmissionAPI) { node.warn("Missing Transmission credentials"); node.status({fill:"red",shape:"ring",text:"Missing Transmission credentials"}); return; } - this.url = n.url || msg.url || ""; + //this.url = n.url || msg.url || ""; node.status({}); node.on("input", function(msg) { + node.log("Entering Add Torrent section"); node.status({fill:"blue",shape:"dot",text:"Calling Transmission"}); + var url; + var msg2 = {}; + url = msg.url || n.url; + node.log(url); - TransmissionAPI.addUrl( this.url,function(err, result) { + TransmissionAPI.addUrl(url,function(err, result) { if (err) { node.error("failed to add Torrent Url : " + err); node.log( JSON.stringify( err )); @@ -130,4 +135,52 @@ module.exports = function(RED) { } RED.nodes.registerType("Transmission Add Torrent", TransmissonTorrentAdd); + function TransmissonTorrentRemove(n) { + RED.nodes.createNode(this,n); + this.config = RED.nodes.getNode(n.config); + var node = this; + var TransmissionAPI = this.config ? this.config.TransmissionAPI : null; + + if (!TransmissionAPI) { + node.warn("Missing Transmission credentials"); + node.status({fill:"red",shape:"ring",text:"Missing Transmission credentials"}); + return; + } + + //this.url = n.url || msg.url || ""; + + node.status({}); + node.on("input", function(msg) { + node.log("Entering Remove Torrent section"); + node.status({fill:"blue",shape:"dot",text:"Calling Transmission"}); + var ids; + var msg2 = {}; + ids = msg.ids || n.ids; + node.log(ids); + + TransmissionAPI.remove(ids,function(err, result) { + if (err) { + node.error("failed to select Torrent ids : " + err); + node.log( JSON.stringify( err )); + + node.status({fill:"red",shape:"ring",text:"error"}); + return; + } + + node.status({}); + + node.status({fill:"green",shape:"dot",text:"processing"}); + + msg.topic = "/transmission.v1/torrentRemove"; + msg.payload = result; + node.send(msg); + + node.status({}); + + }) + }) + + } + RED.nodes.registerType("Transmission Remove Torrent", TransmissonTorrentRemove); + }