Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# LICENSE

Copyright 2014, 2015 Andrew D Lindsay @AndrewDLindsay <http://blog.thiseldo.co.uk>

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.
60 changes: 51 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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: <https://github.com/FLYBYME/node-transmission>

## 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 (<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>)

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 (<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>)

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 (<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>)

## To Do

1. [ ] Add the other Transmission functions from <https://github.com/FLYBYME/node-transmission>

## 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
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
]

}
56 changes: 51 additions & 5 deletions transmission.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@


<script type="text/x-red" data-template-name="Transmission List Torrents">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-config"><i class="fa fa-user"></i> Transmission API</label>
<input type="text" id="node-input-config">
Expand All @@ -52,7 +56,7 @@

<script type="text/javascript">
RED.nodes.registerType('Transmission List Torrents',{
category: 'advanced',
category: 'transmission',
color:"#C0DEED",
defaults: {
config: {type:"transmission-config",required:true},
Expand All @@ -62,13 +66,17 @@
outputs:1,
icon: "transmission.png",
label: function() {
return this.name ? this.name : "Transmission";
return this.name||"List Torrents";
}
});
</script>


<script type="text/x-red" data-template-name="Transmission Add Torrent">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-config"><i class="fa fa-user"></i> Transmission API</label>
<input type="text" id="node-input-config">
Expand All @@ -87,19 +95,57 @@

<script type="text/javascript">
RED.nodes.registerType('Transmission Add Torrent',{
category: 'advanced',
category: 'transmission',
color:"#C0DEED",
defaults: {
config: {type:"transmission-config",required:true},
url: {value: "",required:true},
url: {value: "",required:false},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "transmission.png",
label: function() {
return this.name ? this.name : "TransmissonTorrentAdd";
return this.name||"Add Torrent";
}
});
</script>

<script type="text/x-red" data-template-name="Transmission Remove Torrent">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-config"><i class="fa fa-user"></i> Transmission API</label>
<input type="text" id="node-input-config">
</div>
<div class="form-row node-input-ids">
<label for="node-input-ids"><i class="fa fa-tag"></i> Ids</label>
<input type="text" id="node-input-ids" placeholder="hashString">
</div>
</script>

<script type="text/x-red" data-help-name="Transmission Remove Torrent">
<p>Remove a torrent using the hashString value of a torrent in Transmission using 'msg.ids'.</p>
<p>Returns an empty object in msg.payload with a msg.topic of '/transmission.v1/torrentRemove'</p>
<p>See the 3.3 Torrent Accessors section of the RPC-Spec <a href="https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt" target="_blank">https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt</a>
</script>

<script type="text/javascript">
RED.nodes.registerType('Transmission Remove Torrent',{
category: 'transmission',
color:"#C0DEED",
defaults: {
config: {type:"transmission-config",required:true},
ids: {value: "",required:false},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "transmission.png",
label: function() {
return this.name||"Remove Torrent";
}
});
</script>
59 changes: 56 additions & 3 deletions transmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ));
Expand All @@ -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);

}