mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-17 15:59:36 +02:00
New: rTorrent - Don't start download automatically (#3222)
This commit is contained in:
parent
92b5822a39
commit
ff894d5210
@ -54,11 +54,11 @@ public void Setup()
|
|||||||
protected void GivenSuccessfulDownload()
|
protected void GivenSuccessfulDownload()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IRTorrentProxy>()
|
Mocker.GetMock<IRTorrentProxy>()
|
||||||
.Setup(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<RTorrentPriority>(), It.IsAny<string>(), It.IsAny<RTorrentSettings>()))
|
.Setup(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<RTorrentPriority>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<RTorrentSettings>()))
|
||||||
.Callback(PrepareClientToReturnCompletedItem);
|
.Callback(PrepareClientToReturnCompletedItem);
|
||||||
|
|
||||||
Mocker.GetMock<IRTorrentProxy>()
|
Mocker.GetMock<IRTorrentProxy>()
|
||||||
.Setup(s => s.AddTorrentFromFile(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<RTorrentPriority>(), It.IsAny<string>(), It.IsAny<RTorrentSettings>()))
|
.Setup(s => s.AddTorrentFromFile(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<RTorrentPriority>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<RTorrentSettings>()))
|
||||||
.Callback(PrepareClientToReturnCompletedItem);
|
.Callback(PrepareClientToReturnCompletedItem);
|
||||||
|
|
||||||
|
|
||||||
@ -123,4 +123,4 @@ public void Download_should_return_unique_id()
|
|||||||
id.Should().NotBeNullOrEmpty();
|
id.Should().NotBeNullOrEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash
|
|||||||
{
|
{
|
||||||
var priority = (RTorrentPriority)(remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority);
|
var priority = (RTorrentPriority)(remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority);
|
||||||
|
|
||||||
_proxy.AddTorrentFromUrl(magnetLink, Settings.MovieCategory, priority, Settings.MovieDirectory, Settings);
|
_proxy.AddTorrentFromUrl(magnetLink, Settings.MovieCategory, priority, Settings.MovieDirectory, Settings.DontStartAutomatically, Settings);
|
||||||
|
|
||||||
var tries = 10;
|
var tries = 10;
|
||||||
var retryDelay = 500;
|
var retryDelay = 500;
|
||||||
@ -63,7 +63,7 @@ protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string has
|
|||||||
{
|
{
|
||||||
var priority = (RTorrentPriority)(remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority);
|
var priority = (RTorrentPriority)(remoteMovie.Movie.IsRecentMovie ? Settings.RecentMoviePriority : Settings.OlderMoviePriority);
|
||||||
|
|
||||||
_proxy.AddTorrentFromFile(filename, fileContent, Settings.MovieCategory, priority, Settings.MovieDirectory, Settings);
|
_proxy.AddTorrentFromFile(filename, fileContent, Settings.MovieCategory, priority, Settings.MovieDirectory, Settings.DontStartAutomatically, Settings);
|
||||||
|
|
||||||
var tries = 10;
|
var tries = 10;
|
||||||
var retryDelay = 500;
|
var retryDelay = 500;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -13,8 +13,8 @@ public interface IRTorrentProxy
|
|||||||
string GetVersion(RTorrentSettings settings);
|
string GetVersion(RTorrentSettings settings);
|
||||||
List<RTorrentTorrent> GetTorrents(RTorrentSettings settings);
|
List<RTorrentTorrent> GetTorrents(RTorrentSettings settings);
|
||||||
|
|
||||||
void AddTorrentFromUrl(string torrentUrl, string label, RTorrentPriority priority, string directory, RTorrentSettings settings);
|
void AddTorrentFromUrl(string torrentUrl, string label, RTorrentPriority priority, string directory, bool doNotStart, RTorrentSettings settings);
|
||||||
void AddTorrentFromFile(string fileName, byte[] fileContent, string label, RTorrentPriority priority, string directory, RTorrentSettings settings);
|
void AddTorrentFromFile(string fileName, byte[] fileContent, string label, RTorrentPriority priority, string directory, bool doNotStart, RTorrentSettings settings);
|
||||||
void RemoveTorrent(string hash, RTorrentSettings settings);
|
void RemoveTorrent(string hash, RTorrentSettings settings);
|
||||||
bool HasHashTorrent(string hash, RTorrentSettings settings);
|
bool HasHashTorrent(string hash, RTorrentSettings settings);
|
||||||
}
|
}
|
||||||
@ -24,9 +24,15 @@ public interface IRTorrent : IXmlRpcProxy
|
|||||||
[XmlRpcMethod("d.multicall2")]
|
[XmlRpcMethod("d.multicall2")]
|
||||||
object[] TorrentMulticall(params string[] parameters);
|
object[] TorrentMulticall(params string[] parameters);
|
||||||
|
|
||||||
|
[XmlRpcMethod("load.normal")]
|
||||||
|
int Load(string target, string data, params string[] commands);
|
||||||
|
|
||||||
[XmlRpcMethod("load.start")]
|
[XmlRpcMethod("load.start")]
|
||||||
int LoadStart(string target, string data, params string[] commands);
|
int LoadStart(string target, string data, params string[] commands);
|
||||||
|
|
||||||
|
[XmlRpcMethod("load.raw")]
|
||||||
|
int LoadRaw(string target, byte[] data, params string[] commands);
|
||||||
|
|
||||||
[XmlRpcMethod("load.raw_start")]
|
[XmlRpcMethod("load.raw_start")]
|
||||||
int LoadRawStart(string target, byte[] data, params string[] commands);
|
int LoadRawStart(string target, byte[] data, params string[] commands);
|
||||||
|
|
||||||
@ -102,26 +108,50 @@ public List<RTorrentTorrent> GetTorrents(RTorrentSettings settings)
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTorrentFromUrl(string torrentUrl, string label, RTorrentPriority priority, string directory, RTorrentSettings settings)
|
public void AddTorrentFromUrl(string torrentUrl, string label, RTorrentPriority priority, string directory, bool doNotStart, RTorrentSettings settings)
|
||||||
{
|
{
|
||||||
_logger.Debug("Executing remote method: load.normal");
|
_logger.Debug("Adding Torrent From URL");
|
||||||
|
|
||||||
var client = BuildClient(settings);
|
var client = BuildClient(settings);
|
||||||
|
|
||||||
var response = client.LoadStart("", torrentUrl, GetCommands(label, priority, directory));
|
var response = -1;
|
||||||
|
|
||||||
|
if (doNotStart)
|
||||||
|
{
|
||||||
|
_logger.Debug("Executing remote method load.normal");
|
||||||
|
response = client.Load("", torrentUrl, GetCommands(label, priority, directory));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Debug("Executing remote method load.start");
|
||||||
|
response = client.LoadStart("", torrentUrl, GetCommands(label, priority, directory));
|
||||||
|
}
|
||||||
|
|
||||||
if (response != 0)
|
if (response != 0)
|
||||||
{
|
{
|
||||||
throw new DownloadClientException("Could not add torrent: {0}.", torrentUrl);
|
throw new DownloadClientException("Could not add torrent: {0}.", torrentUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTorrentFromFile(string fileName, byte[] fileContent, string label, RTorrentPriority priority, string directory, RTorrentSettings settings)
|
public void AddTorrentFromFile(string fileName, byte[] fileContent, string label, RTorrentPriority priority, string directory, bool doNotStart, RTorrentSettings settings)
|
||||||
{
|
{
|
||||||
_logger.Debug("Executing remote method: load.raw");
|
_logger.Debug("Loading Torrent from File");
|
||||||
|
|
||||||
var client = BuildClient(settings);
|
var client = BuildClient(settings);
|
||||||
|
|
||||||
var response = client.LoadRawStart("", fileContent, GetCommands(label, priority, directory));
|
var response = -1;
|
||||||
|
|
||||||
|
if (doNotStart)
|
||||||
|
{
|
||||||
|
_logger.Debug("Executing remote method load.raw");
|
||||||
|
response = client.LoadRaw("", fileContent, GetCommands(label, priority, directory));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Debug("Executing remote method load.raw_start");
|
||||||
|
response = client.LoadRawStart("", fileContent, GetCommands(label, priority, directory));
|
||||||
|
}
|
||||||
|
|
||||||
if (response != 0)
|
if (response != 0)
|
||||||
{
|
{
|
||||||
throw new DownloadClientException("Could not add torrent: {0}.", fileName);
|
throw new DownloadClientException("Could not add torrent: {0}.", fileName);
|
||||||
@ -202,4 +232,4 @@ private IRTorrent BuildClient(RTorrentSettings settings)
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ public RTorrentSettings()
|
|||||||
[FieldDefinition(9, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
|
[FieldDefinition(9, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing movies that released over 21 days ago")]
|
||||||
public int OlderMoviePriority { get; set; }
|
public int OlderMoviePriority { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(10, Label = "Don't start download automatically", Type = FieldType.Checkbox, Advanced = true, HelpText = "Add Download in a stopped state. This is useful for letting a Queue manager like pyrotorque automatically start the download.")]
|
||||||
|
public bool DontStartAutomatically { get; set; }
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user