parent
b626c5bbf0
commit
39b99341cd
@ -1,111 +1,161 @@
|
|||||||
using CookComputing.XmlRpc;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using System.Xml.XPath;
|
||||||
|
using NzbDrone.Core.Download.Extensions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients.Aria2
|
namespace NzbDrone.Core.Download.Clients.Aria2
|
||||||
{
|
{
|
||||||
public class Aria2Version
|
public class Aria2Fault
|
||||||
{
|
{
|
||||||
[XmlRpcMember("version")]
|
public Aria2Fault(XElement element)
|
||||||
public string Version;
|
{
|
||||||
|
foreach (var e in element.XPathSelectElements("./value/struct/member"))
|
||||||
[XmlRpcMember("enabledFeatures")]
|
{
|
||||||
public string[] EnabledFeatures;
|
var name = e.ElementAsString("name");
|
||||||
|
if (name == "faultCode")
|
||||||
|
{
|
||||||
|
FaultCode = e.Element("value").ElementAsInt("int");
|
||||||
|
}
|
||||||
|
else if (name == "faultString")
|
||||||
|
{
|
||||||
|
FaultString = e.Element("value").GetStringValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int FaultCode { get; set; }
|
||||||
|
public string FaultString { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Aria2Uri
|
public class Aria2Version
|
||||||
{
|
{
|
||||||
[XmlRpcMember("status")]
|
public Aria2Version(XElement element)
|
||||||
public string Status;
|
{
|
||||||
|
foreach (var e in element.XPathSelectElements("./struct/member"))
|
||||||
[XmlRpcMember("uri")]
|
{
|
||||||
public string Uri;
|
if (e.ElementAsString("name") == "version")
|
||||||
|
{
|
||||||
|
Version = e.Element("value").GetStringValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Version { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Aria2File
|
public class Aria2File
|
||||||
{
|
{
|
||||||
[XmlRpcMember("index")]
|
public Aria2File(XElement element)
|
||||||
public string Index;
|
{
|
||||||
|
foreach (var e in element.XPathSelectElements("./struct/member"))
|
||||||
[XmlRpcMember("length")]
|
{
|
||||||
public string Length;
|
var name = e.ElementAsString("name");
|
||||||
|
|
||||||
|
if (name == "path")
|
||||||
|
{
|
||||||
|
Path = e.Element("value").GetStringValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Path { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[XmlRpcMember("completedLength")]
|
public class Aria2Dict
|
||||||
public string CompletedLength;
|
{
|
||||||
|
public Aria2Dict(XElement element)
|
||||||
|
{
|
||||||
|
Dict = new Dictionary<string, string>();
|
||||||
|
|
||||||
[XmlRpcMember("path")]
|
foreach (var e in element.XPathSelectElements("./struct/member"))
|
||||||
public string Path;
|
{
|
||||||
|
Dict.Add(e.ElementAsString("name"), e.Element("value").GetStringValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[XmlRpcMember("selected")]
|
public Dictionary<string, string> Dict { get; set; }
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string Selected;
|
|
||||||
|
|
||||||
[XmlRpcMember("uris")]
|
public class Aria2Bittorrent
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
{
|
||||||
public Aria2Uri[] Uris;
|
public Aria2Bittorrent(XElement element)
|
||||||
|
{
|
||||||
|
foreach (var e in element.Descendants("member"))
|
||||||
|
{
|
||||||
|
if (e.ElementAsString("name") == "name")
|
||||||
|
{
|
||||||
|
Name = e.Element("value").GetStringValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Aria2Status
|
public class Aria2Status
|
||||||
{
|
{
|
||||||
[XmlRpcMember("bittorrent")]
|
public Aria2Status(XElement element)
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
{
|
||||||
public XmlRpcStruct Bittorrent;
|
foreach (var e in element.XPathSelectElements("./struct/member"))
|
||||||
|
{
|
||||||
[XmlRpcMember("bitfield")]
|
var name = e.ElementAsString("name");
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
|
||||||
public string Bitfield;
|
if (name == "bittorrent")
|
||||||
|
{
|
||||||
[XmlRpcMember("infoHash")]
|
Bittorrent = new Aria2Bittorrent(e.Element("value"));
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string InfoHash;
|
else if (name == "infoHash")
|
||||||
|
{
|
||||||
[XmlRpcMember("completedLength")]
|
InfoHash = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string CompletedLength;
|
else if (name == "completedLength")
|
||||||
|
{
|
||||||
[XmlRpcMember("connections")]
|
CompletedLength = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string Connections;
|
else if (name == "downloadSpeed")
|
||||||
|
{
|
||||||
[XmlRpcMember("dir")]
|
DownloadSpeed = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string Dir;
|
else if (name == "files")
|
||||||
|
{
|
||||||
[XmlRpcMember("downloadSpeed")]
|
Files = e.XPathSelectElement("./value/array/data")
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
.Elements()
|
||||||
public string DownloadSpeed;
|
.Select(x => new Aria2File(x))
|
||||||
|
.ToArray();
|
||||||
[XmlRpcMember("files")]
|
}
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
else if (name == "gid")
|
||||||
public Aria2File[] Files;
|
{
|
||||||
|
Gid = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMember("gid")]
|
}
|
||||||
public string Gid;
|
else if (name == "status")
|
||||||
|
{
|
||||||
[XmlRpcMember("numPieces")]
|
Status = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string NumPieces;
|
else if (name == "totalLength")
|
||||||
|
{
|
||||||
[XmlRpcMember("pieceLength")]
|
TotalLength = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string PieceLength;
|
else if (name == "uploadLength")
|
||||||
|
{
|
||||||
[XmlRpcMember("status")]
|
UploadLength = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string Status;
|
else if (name == "errorMessage")
|
||||||
|
{
|
||||||
[XmlRpcMember("totalLength")]
|
ErrorMessage = e.Element("value").GetStringValue();
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
}
|
||||||
public string TotalLength;
|
}
|
||||||
|
}
|
||||||
[XmlRpcMember("uploadLength")]
|
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
public Aria2Bittorrent Bittorrent { get; set; }
|
||||||
public string UploadLength;
|
public string InfoHash { get; set; }
|
||||||
|
public string CompletedLength { get; set; }
|
||||||
[XmlRpcMember("uploadSpeed")]
|
public string DownloadSpeed { get; set; }
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
public Aria2File[] Files { get; set; }
|
||||||
public string UploadSpeed;
|
public string Gid { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
[XmlRpcMember("errorMessage")]
|
public string TotalLength { get; set; }
|
||||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
public string UploadLength { get; set; }
|
||||||
public string ErrorMessage;
|
public string ErrorMessage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue