New: Initial state for torrents added to UTorrent

Closes #409
This commit is contained in:
Mark McDowall 2017-08-22 20:48:53 -07:00
parent bea4954de9
commit 19a4d3536b
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
5 changed files with 18 additions and 31 deletions

View File

@ -49,14 +49,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
_proxy.MoveTorrentToTopInQueue(hash, Settings);
}
if (Settings.AddStopped)
{
_proxy.StopTorrent(hash, Settings);
}
else
{
_proxy.StartTorrent(hash, Settings);
}
_proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings);
return hash;
}
@ -74,14 +67,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
_proxy.MoveTorrentToTopInQueue(hash, Settings);
}
if (Settings.AddStopped)
{
_proxy.StopTorrent(hash, Settings);
}
else
{
_proxy.StartTorrent(hash, Settings);
}
_proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings);
return hash;
}

View File

@ -22,8 +22,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
void RemoveTorrent(string hash, bool removeData, UTorrentSettings settings);
void SetTorrentLabel(string hash, string label, UTorrentSettings settings);
void MoveTorrentToTopInQueue(string hash, UTorrentSettings settings);
void StartTorrent(string hash, UTorrentSettings settings);
void StopTorrent(string hash, UTorrentSettings settings);
void SetState(string hash, UTorrentState state, UTorrentSettings settings);
}
public class UTorrentProxy : IUTorrentProxy
@ -159,19 +158,10 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
ProcessRequest(requestBuilder, settings);
}
public void StartTorrent(string hash, UTorrentSettings settings)
public void SetState(string hash, UTorrentState state, UTorrentSettings settings)
{
var requestBuilder = BuildRequest(settings)
.AddQueryParam("action", "start")
.AddQueryParam("hash", hash);
ProcessRequest(requestBuilder, settings);
}
public void StopTorrent(string hash, UTorrentSettings settings)
{
var requestBuilder = BuildRequest(settings)
.AddQueryParam("action", "stop")
.AddQueryParam("action", state.ToString().ToLowerInvariant())
.AddQueryParam("hash", hash);
ProcessRequest(requestBuilder, settings);

View File

@ -47,8 +47,8 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
[FieldDefinition(6, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(UTorrentPriority), HelpText = "Priority to use when grabbing episodes that aired over 14 days ago")]
public int OlderTvPriority { get; set; }
[FieldDefinition(7, Label = "Add Stopped", Type = FieldType.Checkbox, SelectOptions = typeof(UTorrentPriority), HelpText = "Torrents will need to be started manually in uTorrent")]
public bool AddStopped { get; set; }
[FieldDefinition(7, Label = "Initial State", Type = FieldType.Select, SelectOptions = typeof(UTorrentState), HelpText = "Initial state for torrents added to uTorrent")]
public int IntialState { get; set; }
public NzbDroneValidationResult Validate()
{

View File

@ -0,0 +1,10 @@
namespace NzbDrone.Core.Download.Clients.UTorrent
{
public enum UTorrentState
{
Start = 0,
ForceStart = 1,
Pause = 2,
Stop = 3
}
}

View File

@ -495,6 +495,7 @@
<Compile Include="Download\Clients\uTorrent\UTorrentProxy.cs" />
<Compile Include="Download\Clients\uTorrent\UTorrentResponse.cs" />
<Compile Include="Download\Clients\uTorrent\UTorrentSettings.cs" />
<Compile Include="Download\Clients\uTorrent\UtorrentState.cs" />
<Compile Include="Download\Clients\uTorrent\UTorrentTorrent.cs" />
<Compile Include="Download\Clients\uTorrent\UTorrentTorrentCache.cs" />
<Compile Include="Download\Clients\uTorrent\UTorrentTorrentStatus.cs" />