Skip to content

Updated to Transmission RPC specification as of Transmission 4.1.0 #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Transmission-RPC-API
[Official Transmission RPC specs](https://github.com/transmission/transmission/blob/master/extras/rpc-spec.txt)

C# implementation of the Transmission RPC API.
Up to date with Transmission RPC specification as of Transmission 4.1.0 (rpc-version-semver 5.4.0, rpc-version: 18)

| Command | Not Implemented | Implemented|
| -------------------- |:-:|:-:|
Expand All @@ -32,6 +33,9 @@ C# implementation of the Transmission RPC API.
| queue-move-down | | x |
| queue-move-bottom | | x |
| free-space | | x |
| group-set | | x |
| group-get | | x |


How to use
-------------
Expand Down
20 changes: 10 additions & 10 deletions Transmission.API.RPC.Test/MethodsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void AddTorrent_Test()
var newTorrentInfo = client.TorrentAdd(torrent);

Assert.IsNotNull(newTorrentInfo);
Assert.IsTrue(newTorrentInfo.ID != 0);
Assert.IsTrue(newTorrentInfo.Id != 0);
}

[TestMethod]
Expand All @@ -59,7 +59,7 @@ public void AddTorrent_Magnet_Test()
var newTorrentInfo = client.TorrentAdd(torrent);

Assert.IsNotNull(newTorrentInfo);
Assert.IsTrue(newTorrentInfo.ID != 0);
Assert.IsTrue(newTorrentInfo.Id != 0);
}

[TestMethod]
Expand All @@ -84,13 +84,13 @@ public void SetTorrentSettings_Test()
var trackerCount = torrentInfo.Trackers.Length;
TorrentSettings settings = new TorrentSettings()
{
IDs = new object[] { torrentInfo.HashString },
TrackerRemove = new int[] { trackerInfo.ID }
Ids = new object[] { torrentInfo.HashString },
TrackerRemove = new long[] { trackerInfo.Id }
};

client.TorrentSet(settings);

torrentsInfo = client.TorrentGet(TorrentFields.ALL_FIELDS, torrentInfo.ID);
torrentsInfo = client.TorrentGet(TorrentFields.ALL_FIELDS, torrentInfo.Id);
torrentInfo = torrentsInfo.Torrents.FirstOrDefault();

Assert.IsFalse(trackerCount == torrentInfo.Trackers.Length);
Expand All @@ -103,10 +103,10 @@ public void RenamePathTorrent_Test()
var torrentInfo = torrentsInfo.Torrents.FirstOrDefault();
Assert.IsNotNull(torrentInfo, "Torrent not found");

var result = client.TorrentRenamePath(torrentInfo.ID, torrentInfo.Files[0].Name, "test_" + torrentInfo.Files[0].Name);
var result = client.TorrentRenamePath(torrentInfo.Id, torrentInfo.Files[0].Name, "test_" + torrentInfo.Files[0].Name);

Assert.IsNotNull(result, "Torrent not found");
Assert.IsTrue(result.ID != 0);
Assert.IsTrue(result.Id != 0);
}

[TestMethod]
Expand All @@ -116,11 +116,11 @@ public void RemoveTorrent_Test()
var torrentInfo = torrentsInfo.Torrents.FirstOrDefault();
Assert.IsNotNull(torrentInfo, "Torrent not found");

client.TorrentRemove(new int[] { torrentInfo.ID });
client.TorrentRemove(new long[] { torrentInfo.Id });

torrentsInfo = client.TorrentGet(TorrentFields.ALL_FIELDS);

Assert.IsFalse(torrentsInfo.Torrents.Any(t => t.ID == torrentInfo.ID));
Assert.IsFalse(torrentsInfo.Torrents.Any(t => t.Id == torrentInfo.Id));
}

#endregion
Expand All @@ -142,7 +142,7 @@ public void ChangeSessionTest()
var sessionInformation = client.GetSessionInformation();

//Save old speed limit up
var oldSpeedLimit = sessionInformation.SpeedLimitUp;
var oldSpeedLimit = (long)sessionInformation.SpeedLimitUp;

//Set new session settings
client.SetSessionSettings(new SessionSettings() { SpeedLimitUp = 100 });
Expand Down
2 changes: 1 addition & 1 deletion Transmission.API.RPC.Test/Transmission.API.RPC.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
43 changes: 43 additions & 0 deletions Transmission.API.RPC/Arguments/BandwidthGroupSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;
using Transmission.API.RPC.Common;

namespace Transmission.API.RPC.Arguments
{
/// <summary>
/// Bandwidth group settings for editing bandwidth groups
/// </summary>
public class BandwidthGroupSettings : ArgumentsBase
{
/// <summary>
/// Session limits are honored
/// </summary>
public bool HonorsSessionLimits { get { return GetValue<bool>("honorsSessionLimits"); } set { this["honorsSessionLimits"] = value; } }

/// <summary>
/// Name of the bandwidth group
/// </summary>
public string Name { get { return GetValue<string>("name"); } set { this["name"] = value; } }

/// <summary>
/// Max global download speed of this bandwidth group (KBps)
/// </summary>
public long SpeedLimitDown { get { return GetValue<long>("speed-limit-down"); } set { this["speed-limit-down"] = value; } }

/// <summary>
/// True means enabled
/// </summary>
public bool SpeedLimitDownEnabled { get { return GetValue<bool>("speed-limit-down-enabled"); } set { this["speed-limit-down-enabled"] = value; } }

/// <summary>
/// Max global upload speed of this bandwidth group (KBps)
/// </summary>
public long SpeedLimitUp { get { return GetValue<long>("speed-limit-up"); } set { this["speed-limit-up"] = value; } }

/// <summary>
/// True means enabled
/// </summary>
public bool SpeedLimitUpEnabled { get { return GetValue<bool>("speed-limit-up-enabled"); } set { this["speed-limit-up-enabled"] = value; } }
}
}
19 changes: 12 additions & 7 deletions Transmission.API.RPC/Arguments/NewTorrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class NewTorrent : ArgumentsBase
/// </summary>
public string Filename { get { return GetValue<string>("filename"); } set { this["filename"] = value; } }

/// <summary>
/// Array of labels applied to the torrent
/// </summary>
public string[] Labels { get { return GetValue<string[]>("labels"); } set { this["labels"] = value; } }

/// <summary>
/// base64-encoded .torrent content
/// </summary>
Expand All @@ -41,36 +46,36 @@ public class NewTorrent : ArgumentsBase
/// <summary>
/// maximum number of peers
/// </summary>
public int? PeerLimit { get { return GetValue<int?>("peer-limit"); } set { this["peer-limit"] = value; } }
public long PeerLimit { get { return GetValue<long>("peer-limit"); } set { this["peer-limit"] = value; } }

/// <summary>
/// Torrent's bandwidth priority
/// </summary>
public int? BandwidthPriority { get { return GetValue<int?>("bandwidthPriority"); } set { this["bandwidthPriority"] = value; } }
public long BandwidthPriority { get { return GetValue<long>("bandwidthPriority"); } set { this["bandwidthPriority"] = value; } }

/// <summary>
/// Indices of file(s) to download
/// </summary>
public int[] FilesWanted { get { return GetValue<int[]>("files-wanted"); } set { this["files-wanted"] = value; } }
public long[] FilesWanted { get { return GetValue<long[]>("files-wanted"); } set { this["files-wanted"] = value; } }

/// <summary>
/// Indices of file(s) to download
/// </summary>
public int[] FilesUnwanted { get { return GetValue<int[]>("files-unwanted"); } set { this["files-unwanted"] = value; } }
public long[] FilesUnwanted { get { return GetValue<long[]>("files-unwanted"); } set { this["files-unwanted"] = value; } }

/// <summary>
/// Indices of high-priority file(s)
/// </summary>
public int[] PriorityHigh { get { return GetValue<int[]>("priority-high"); } set { this["priority-high"] = value; } }
public long[] PriorityHigh { get { return GetValue<long[]>("priority-high"); } set { this["priority-high"] = value; } }

/// <summary>
/// Indices of low-priority file(s)
/// </summary>
public int[] PriorityLow { get { return GetValue<int[]>("priority-low"); } set { this["priority-low"] = value; } }
public long[] PriorityLow { get { return GetValue<long[]>("priority-low"); } set { this["priority-low"] = value; } }

/// <summary>
/// Indices of normal-priority file(s)
/// </summary>
public int[] PriorityNormal { get { return GetValue<int[]>("priority-normal"); } set { this["priority-normal"] = value; } }
public long[] PriorityNormal { get { return GetValue<long[]>("priority-normal"); } set { this["priority-normal"] = value; } }
}
}
25 changes: 25 additions & 0 deletions Transmission.API.RPC/Arguments/PortTestProtocol.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Transmission.API.RPC.Arguments
{
/// <summary>
/// Which protocol was used for the port test
/// </summary>
public enum PortTestProtocol
{
/// <summary>
/// IPv4
/// </summary>
IPv4 = 0,
/// <summary>
/// IPv6
/// </summary>
IPV6,
/// <summary>
/// Could not be determined
/// </summary>
Unknown,
}
}
Loading