Skip to content

Commit ca22a25

Browse files
committed
New: Add stopped option for rTorrent
1 parent ff9a9a5 commit ca22a25

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentPriority.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
22
{
33
public enum RTorrentPriority
44
{
5-
DoNotDownload = 0,
5+
VeryLow = 0,
66
Low = 1,
77
Normal = 2,
88
High = 3

src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Net;
@@ -26,9 +26,15 @@ public interface IRTorrent : IXmlRpcProxy
2626
[XmlRpcMethod("d.multicall2")]
2727
object[] TorrentMulticall(params string[] parameters);
2828

29+
[XmlRpcMethod("load.normal")]
30+
int LoadNormal(string target, string data, params string[] commands);
31+
2932
[XmlRpcMethod("load.start")]
3033
int LoadStart(string target, string data, params string[] commands);
3134

35+
[XmlRpcMethod("load.raw")]
36+
int LoadRaw(string target, byte[] data, params string[] commands);
37+
3238
[XmlRpcMethod("load.raw_start")]
3339
int LoadRawStart(string target, byte[] data, params string[] commands);
3440

@@ -107,10 +113,20 @@ public List<RTorrentTorrent> GetTorrents(RTorrentSettings settings)
107113

108114
public void AddTorrentFromUrl(string torrentUrl, string label, RTorrentPriority priority, string directory, RTorrentSettings settings)
109115
{
110-
_logger.Debug("Executing remote method: load.normal");
111-
112116
var client = BuildClient(settings);
113-
var response = ExecuteRequest(() => client.LoadStart("", torrentUrl, GetCommands(label, priority, directory)));
117+
var response = ExecuteRequest(() =>
118+
{
119+
if (settings.AddStopped)
120+
{
121+
_logger.Debug("Executing remote method: load.normal");
122+
return client.LoadNormal("", torrentUrl, GetCommands(label, priority, directory));
123+
}
124+
else
125+
{
126+
_logger.Debug("Executing remote method: load.start");
127+
return client.LoadStart("", torrentUrl, GetCommands(label, priority, directory));
128+
}
129+
});
114130

115131
if (response != 0)
116132
{
@@ -120,10 +136,20 @@ public void AddTorrentFromUrl(string torrentUrl, string label, RTorrentPriority
120136

121137
public void AddTorrentFromFile(string fileName, byte[] fileContent, string label, RTorrentPriority priority, string directory, RTorrentSettings settings)
122138
{
123-
_logger.Debug("Executing remote method: load.raw");
124-
125139
var client = BuildClient(settings);
126-
var response = ExecuteRequest(() => client.LoadRawStart("", fileContent, GetCommands(label, priority, directory)));
140+
var response = ExecuteRequest(() =>
141+
{
142+
if (settings.AddStopped)
143+
{
144+
_logger.Debug("Executing remote method: load.raw");
145+
return client.LoadRaw("", fileContent, GetCommands(label, priority, directory));
146+
}
147+
else
148+
{
149+
_logger.Debug("Executing remote method: load.raw_start");
150+
return client.LoadRawStart("", fileContent, GetCommands(label, priority, directory));
151+
}
152+
});
127153

128154
if (response != 0)
129155
{

src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FluentValidation;
1+
using FluentValidation;
22
using NzbDrone.Core.Annotations;
33
using NzbDrone.Core.ThingiProvider;
44
using NzbDrone.Core.Validation;
@@ -61,6 +61,9 @@ public RTorrentSettings()
6161
[FieldDefinition(9, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing episodes that aired over 14 days ago")]
6262
public int OlderTvPriority { get; set; }
6363

64+
[FieldDefinition(10, Label = "Add Stopped", Type = FieldType.Checkbox, HelpText = "Enabling will prevent magnets from downloading before downloading")]
65+
public bool AddStopped { get; set; }
66+
6467
public NzbDroneValidationResult Validate()
6568
{
6669
return new NzbDroneValidationResult(Validator.Validate(this));

0 commit comments

Comments
 (0)