1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-25 17:17:02 +00:00

Merge pull request #565 from larsjohnsen/rtorrent-fixes

rTorrent: Update method names, enable compression on XMLRPC
This commit is contained in:
Taloth 2015-05-26 19:48:15 +02:00
commit 7a74327761

View file

@ -23,25 +23,25 @@ public interface IRTorrentProxy
public interface IRTorrent : IXmlRpcProxy
{
[XmlRpcMethod("d.multicall")]
object[] TorrentMulticall(params string[] parameters);
[XmlRpcMethod("d.multicall2")]
object[] TorrentMulticall(params string[] parameters);
[XmlRpcMethod("load_start")]
[XmlRpcMethod("load.start")]
int LoadURL(string data);
[XmlRpcMethod("load_raw_start")]
[XmlRpcMethod("load.raw_start")]
int LoadBinary(byte[] data);
[XmlRpcMethod("d.erase")]
int Remove(string hash);
[XmlRpcMethod("d.set_custom1")]
[XmlRpcMethod("d.custom1.set")]
string SetLabel(string hash, string label);
[XmlRpcMethod("d.set_priority")]
[XmlRpcMethod("d.priority.set")]
int SetPriority(string hash, long priority);
[XmlRpcMethod("d.get_name")]
[XmlRpcMethod("d.name")]
string GetName(string hash);
[XmlRpcMethod("system.client_version")]
@ -70,21 +70,21 @@ public string GetVersion(RTorrentSettings settings)
public List<RTorrentTorrent> GetTorrents(RTorrentSettings settings)
{
_logger.Debug("Executing remote method: d.multicall");
_logger.Debug("Executing remote method: d.multicall2");
var client = BuildClient(settings);
var ret = client.TorrentMulticall("main",
"d.get_name=", // string
"d.get_hash=", // string
"d.get_base_path=", // string
"d.get_custom1=", // string (label)
"d.get_size_bytes=", // long
"d.get_left_bytes=", // long
"d.get_down_rate=", // long (in bytes / s)
"d.get_ratio=", // long
var ret = client.TorrentMulticall("", "",
"d.name=", // string
"d.hash=", // string
"d.base_path=", // string
"d.custom1=", // string (label)
"d.size_bytes=", // long
"d.left_bytes=", // long
"d.down.rate=", // long (in bytes / s)
"d.ratio=", // long
"d.is_open=", // long
"d.is_active=", // long
"d.get_complete="); //long
"d.complete="); //long
var items = new List<RTorrentTorrent>();
foreach (object[] torrent in ret)
@ -110,7 +110,7 @@ public List<RTorrentTorrent> GetTorrents(RTorrentSettings settings)
public bool HasHashTorrent(string hash, RTorrentSettings settings)
{
_logger.Debug("Executing remote method: d.get_name");
_logger.Debug("Executing remote method: d.name");
var client = BuildClient(settings);
@ -129,7 +129,7 @@ public bool HasHashTorrent(string hash, RTorrentSettings settings)
public void AddTorrentFromUrl(string torrentUrl, RTorrentSettings settings)
{
_logger.Debug("Executing remote method: load_start");
_logger.Debug("Executing remote method: load.start");
var client = BuildClient(settings);
@ -142,7 +142,7 @@ public void AddTorrentFromUrl(string torrentUrl, RTorrentSettings settings)
public void AddTorrentFromFile(string fileName, Byte[] fileContent, RTorrentSettings settings)
{
_logger.Debug("Executing remote method: load_raw_start");
_logger.Debug("Executing remote method: load.raw_start");
var client = BuildClient(settings);
@ -168,7 +168,7 @@ public void RemoveTorrent(string hash, RTorrentSettings settings)
public void SetTorrentPriority(string hash, RTorrentSettings settings, RTorrentPriority priority)
{
_logger.Debug("Executing remote method: d.set_priority");
_logger.Debug("Executing remote method: d.priority.set");
var client = BuildClient(settings);
@ -203,6 +203,8 @@ private IRTorrent BuildClient(RTorrentSettings settings)
var client = XmlRpcProxyGen.Create<IRTorrent>();
client.Url = url;
client.EnableCompression = true;
if (!settings.Username.IsNullOrWhiteSpace())
{
client.Credentials = new NetworkCredential(settings.Username, settings.Password);