mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
parent
53cf530893
commit
fd17df0dd0
@ -92,6 +92,10 @@ private static XElement ConvertParameter(object value)
|
|||||||
{
|
{
|
||||||
data = new XElement("base64", Convert.ToBase64String(bytes));
|
data = new XElement("base64", Convert.ToBase64String(bytes));
|
||||||
}
|
}
|
||||||
|
else if (value is Dictionary<string, string> d)
|
||||||
|
{
|
||||||
|
data = new XElement("struct", d.Select(p => new XElement("member", new XElement("name", p.Key), new XElement("value", p.Value))));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"Unhandled argument type {value.GetType().Name}");
|
throw new InvalidOperationException($"Unhandled argument type {value.GetType().Name}");
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.Download.Extensions;
|
using NzbDrone.Core.Download.Extensions;
|
||||||
|
|
||||||
@ -97,8 +98,14 @@ public Dictionary<string, string> GetGlobals(Aria2Settings settings)
|
|||||||
|
|
||||||
public string AddMagnet(Aria2Settings settings, string magnet)
|
public string AddMagnet(Aria2Settings settings, string magnet)
|
||||||
{
|
{
|
||||||
var response = ExecuteRequest(settings, "aria2.addUri", GetToken(settings), new List<string> { magnet });
|
var options = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
if (settings.Directory.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
options.Add("dir", settings.Directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = ExecuteRequest(settings, "aria2.addUri", GetToken(settings), new List<string> { magnet }, options);
|
||||||
var gid = response.GetStringResponse();
|
var gid = response.GetStringResponse();
|
||||||
|
|
||||||
return gid;
|
return gid;
|
||||||
@ -106,8 +113,16 @@ public string AddMagnet(Aria2Settings settings, string magnet)
|
|||||||
|
|
||||||
public string AddTorrent(Aria2Settings settings, byte[] torrent)
|
public string AddTorrent(Aria2Settings settings, byte[] torrent)
|
||||||
{
|
{
|
||||||
var response = ExecuteRequest(settings, "aria2.addTorrent", GetToken(settings), torrent);
|
// Aria2's second parameter is an array of URIs and needs to be sent if options are provided, this satisfies that requirement.
|
||||||
|
var emptyListOfUris = new List<string>();
|
||||||
|
var options = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
if (settings.Directory.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
options.Add("dir", settings.Directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = ExecuteRequest(settings, "aria2.addTorrent", GetToken(settings), torrent, emptyListOfUris, options);
|
||||||
var gid = response.GetStringResponse();
|
var gid = response.GetStringResponse();
|
||||||
|
|
||||||
return gid;
|
return gid;
|
||||||
|
@ -41,6 +41,9 @@ public Aria2Settings()
|
|||||||
[FieldDefinition(4, Label = "SecretToken", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
|
[FieldDefinition(4, Label = "SecretToken", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
|
||||||
public string SecretToken { get; set; }
|
public string SecretToken { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(5, Label = "Directory", Type = FieldType.Textbox, HelpText = "DownloadClientAriaSettingsDirectoryHelpText")]
|
||||||
|
public string Directory { get; set; }
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -368,6 +368,7 @@
|
|||||||
"DotNetVersion": ".NET",
|
"DotNetVersion": ".NET",
|
||||||
"Download": "Download",
|
"Download": "Download",
|
||||||
"DownloadClient": "Download Client",
|
"DownloadClient": "Download Client",
|
||||||
|
"DownloadClientAriaSettingsDirectoryHelpText": "Optional location to put downloads in, leave blank to use the default Aria2 location",
|
||||||
"DownloadClientCheckNoneAvailableHealthCheckMessage": "No download client is available",
|
"DownloadClientCheckNoneAvailableHealthCheckMessage": "No download client is available",
|
||||||
"DownloadClientCheckUnableToCommunicateWithHealthCheckMessage": "Unable to communicate with {downloadClientName}. {errorMessage}",
|
"DownloadClientCheckUnableToCommunicateWithHealthCheckMessage": "Unable to communicate with {downloadClientName}. {errorMessage}",
|
||||||
"DownloadClientDelugeSettingsUrlBaseHelpText": "Adds a prefix to the deluge json url, see {url}",
|
"DownloadClientDelugeSettingsUrlBaseHelpText": "Adds a prefix to the deluge json url, see {url}",
|
||||||
|
Loading…
Reference in New Issue
Block a user