Fix Tests & GetItem Implementation

This commit is contained in:
Michael Feinbier 2023-09-17 09:58:22 +02:00
parent b1ec41c990
commit 4452d1c9bf
7 changed files with 189 additions and 310 deletions

View File

@ -1,94 +1,92 @@
/*
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Putio; using NzbDrone.Core.Download.Clients.Putio;
using NzbDrone.Core.MediaFiles.TorrentInfo;
namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests
{ {
[TestFixture]
public class PutioFixture : DownloadClientFixtureBase<Putio> public class PutioFixture : DownloadClientFixtureBase<Putio>
{ {
protected PutioSettings _settings; private PutioSettings _settings;
protected PutioTorrent _queued; private PutioTorrent _queued;
protected PutioTorrent _downloading; private PutioTorrent _downloading;
protected PutioTorrent _failed; private PutioTorrent _failed;
protected PutioTorrent _completed; private PutioTorrent _completed;
protected PutioTorrent _magnet; private PutioTorrent _completed_different_parent;
protected Dictionary<string, object> _PutioAccountSettingsItems; private PutioTorrent _seeding;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
_settings = new PutioSettings _settings = new PutioSettings
{ {
SaveParentId = "1",
}; };
Subject.Definition = new DownloadClientDefinition(); Subject.Definition = new DownloadClientDefinition();
Subject.Definition.Settings = _settings; Subject.Definition.Settings = _settings;
_queued = new PutioTorrent _queued = new PutioTorrent
{ {
HashString = "HASH", Hash = "HASH",
IsFinished = false, Status = PutioTorrentStatus.InQueue,
Status = PutioTorrentStatus.InQueue, Name = _title,
Name = _title, Size = 1000,
TotalSize = 1000, Downloaded = 0,
LeftUntilDone = 1000, SaveParentId = 1
DownloadDir = "somepath" };
};
_downloading = new PutioTorrent _downloading = new PutioTorrent
{ {
HashString = "HASH", Hash = "HASH",
IsFinished = false,
Status = PutioTorrentStatus.Downloading, Status = PutioTorrentStatus.Downloading,
Name = _title, Name = _title,
TotalSize = 1000, Size = 1000,
LeftUntilDone = 100, Downloaded = 980,
DownloadDir = "somepath" SaveParentId = 1,
}; };
_failed = new PutioTorrent _failed = new PutioTorrent
{ {
HashString = "HASH", Hash = "HASH",
IsFinished = false, Status = PutioTorrentStatus.Error,
Status = PutioTorrentStatus.Error, ErrorMessage = "Torrent has reached the maximum number of inactive days.",
Name = _title, Name = _title,
TotalSize = 1000, Size = 1000,
LeftUntilDone = 100, Downloaded = 980,
ErrorString = "Error", SaveParentId = 1,
DownloadDir = "somepath" };
};
_completed = new PutioTorrent _completed = new PutioTorrent
{ {
HashString = "HASH", Hash = "HASH",
IsFinished = true, Status = PutioTorrentStatus.Completed,
Status = PutioTorrentStatus.Completed, Name = _title,
Name = _title, Size = 1000,
TotalSize = 1000, Downloaded = 1000,
LeftUntilDone = 0, SaveParentId = 1,
DownloadDir = "somepath" FileId = 1
}; };
_magnet = new PutioTorrent _completed_different_parent = _completed;
{ _completed_different_parent.SaveParentId = 2;
HashString = "HASH",
IsFinished = false, _seeding = new PutioTorrent
Status = PutioTorrentStatus.Downloading, {
Name = _title, Hash = "HASH",
TotalSize = 0, Status = PutioTorrentStatus.Seeding,
LeftUntilDone = 100, Name = _title,
DownloadDir = "somepath" Size = 1000,
}; Downloaded = 1000,
SaveParentId = 1,
FileId = 2
};
Mocker.GetMock<ITorrentFileInfoReader>() Mocker.GetMock<ITorrentFileInfoReader>()
.Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>())) .Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>()))
@ -96,18 +94,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
_PutioAccountSettingsItems = new Dictionary<string, object>();
_PutioAccountSettingsItems.Add("download-dir", @"C:/Downloads/Finished/Putio");
_PutioAccountSettingsItems.Add("incomplete-dir", null);
_PutioAccountSettingsItems.Add("incomplete-dir-enabled", false);
Mocker.GetMock<IPutioProxy>() Mocker.GetMock<IPutioProxy>()
.Setup(v => v.GetAccountSettings(It.IsAny<PutioSettings>())) .Setup(v => v.GetAccountSettings(It.IsAny<PutioSettings>()));
.Returns(_PutioAccountSettingsItems);
} }
protected void GivenFailedDownload() protected void GivenFailedDownload()
@ -122,7 +112,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[1000])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[1000]));
/*
Mocker.GetMock<IPutioProxy>() Mocker.GetMock<IPutioProxy>()
.Setup(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<PutioSettings>())) .Setup(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<PutioSettings>()))
.Callback(PrepareClientToReturnQueuedItem); .Callback(PrepareClientToReturnQueuedItem);
@ -130,213 +120,72 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests
Mocker.GetMock<IPutioProxy>() Mocker.GetMock<IPutioProxy>()
.Setup(s => s.AddTorrentFromData(It.IsAny<byte[]>(), It.IsAny<PutioSettings>())) .Setup(s => s.AddTorrentFromData(It.IsAny<byte[]>(), It.IsAny<PutioSettings>()))
.Callback(PrepareClientToReturnQueuedItem); .Callback(PrepareClientToReturnQueuedItem);
*/
} }
protected virtual void GivenTorrents(List<PutioTorrent> torrents) protected virtual void GivenTorrents(List<PutioTorrent> torrents)
{ {
if (torrents == null) torrents ??= new List<PutioTorrent>();
{
torrents = new List<PutioTorrent>();
}
Mocker.GetMock<IPutioProxy>() Mocker.GetMock<IPutioProxy>()
.Setup(s => s.GetTorrents(It.IsAny<PutioSettings>())) .Setup(s => s.GetTorrents(It.IsAny<PutioSettings>()))
.Returns(torrents); .Returns(torrents);
} }
protected void PrepareClientToReturnQueuedItem() protected virtual void GivenFile(PutioFile file)
{
file ??= new PutioFile();
Mocker.GetMock<IPutioProxy>()
.Setup(s => s.GetFile(file.Id, It.IsAny<PutioSettings>()))
.Returns(file);
}
[Test]
public void getItems_contains_all_items()
{ {
GivenTorrents(new List<PutioTorrent> GivenTorrents(new List<PutioTorrent>
{ {
_queued,
_downloading,
_failed,
_completed,
_seeding,
_completed_different_parent
});
var items = Subject.GetItems();
VerifyQueued(items.ElementAt(0));
VerifyDownloading(items.ElementAt(1));
VerifyWarning(items.ElementAt(2));
VerifyCompleted(items.ElementAt(3));
VerifyCompleted(items.ElementAt(4));
VerifyCompleted(items.ElementAt(5));
items.Should().HaveCount(6);
}
[TestCase("WAITING", DownloadItemStatus.Queued)]
[TestCase("PREPARING_DOWNLOAD", DownloadItemStatus.Queued)]
[TestCase("COMPLETED", DownloadItemStatus.Completed)]
[TestCase("COMPLETING", DownloadItemStatus.Downloading)]
[TestCase("DOWNLOADING", DownloadItemStatus.Downloading)]
[TestCase("ERROR", DownloadItemStatus.Failed)]
[TestCase("IN_QUEUE", DownloadItemStatus.Queued)]
[TestCase("SEEDING", DownloadItemStatus.Completed)]
public void test_getItems_maps_download_status(string given, DownloadItemStatus expectedItemStatus)
{
_queued.Status = given;
GivenTorrents(new List<PutioTorrent>
{
_queued _queued
}); });
}
protected void PrepareClientToReturnDownloadingItem()
{
GivenTorrents(new List<PutioTorrent>
{
_downloading
});
}
protected void PrepareClientToReturnFailedItem()
{
GivenTorrents(new List<PutioTorrent>
{
_failed
});
}
protected void PrepareClientToReturnCompletedItem()
{
GivenTorrents(new List<PutioTorrent>
{
_completed
});
}
protected void PrepareClientToReturnMagnetItem()
{
GivenTorrents(new List<PutioTorrent>
{
_magnet
});
}
[Test]
public void queued_item_should_have_required_properties()
{
PrepareClientToReturnQueuedItem();
var item = Subject.GetItems().Single();
VerifyQueued(item);
}
[Test]
public void downloading_item_should_have_required_properties()
{
PrepareClientToReturnDownloadingItem();
var item = Subject.GetItems().Single();
VerifyDownloading(item);
}
[Test]
public void failed_item_should_have_required_properties()
{
PrepareClientToReturnFailedItem();
var item = Subject.GetItems().Single();
VerifyWarning(item);
}
[Test]
public void completed_download_should_have_required_properties()
{
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
VerifyCompleted(item);
}
[Test]
public void magnet_download_should_not_return_the_item()
{
PrepareClientToReturnMagnetItem();
Subject.GetItems().Count().Should().Be(0);
}
[Test]
public void Download_should_return_unique_id()
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
var id = Subject.Download(remoteEpisode);
id.Should().NotBeNullOrEmpty();
}
[TestCase("magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp", "CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951")]
public void Download_should_get_hash_from_magnet_url(string magnetUrl, string expectedHash)
{
GivenSuccessfulDownload();
var remoteEpisode = CreateRemoteEpisode();
remoteEpisode.Release.DownloadUrl = magnetUrl;
var id = Subject.Download(remoteEpisode);
id.Should().Be(expectedHash);
}
[TestCase(PutioTorrentStatus.Stopped, DownloadItemStatus.Downloading)]
[TestCase(PutioTorrentStatus.CheckWait, DownloadItemStatus.Downloading)]
[TestCase(PutioTorrentStatus.Check, DownloadItemStatus.Downloading)]
[TestCase(PutioTorrentStatus.Queued, DownloadItemStatus.Queued)]
[TestCase(PutioTorrentStatus.Downloading, DownloadItemStatus.Downloading)]
[TestCase(PutioTorrentStatus.SeedingWait, DownloadItemStatus.Completed)]
[TestCase(PutioTorrentStatus.Seeding, DownloadItemStatus.Completed)]
public void GetItems_should_return_queued_item_as_downloadItemStatus(PutioTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus)
{
_queued.Status = apiStatus;
PrepareClientToReturnQueuedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(PutioTorrentStatus.Queued, DownloadItemStatus.Queued)]
[TestCase(PutioTorrentStatus.Downloading, DownloadItemStatus.Downloading)]
[TestCase(PutioTorrentStatus.Seeding, DownloadItemStatus.Completed)]
public void GetItems_should_return_downloading_item_as_downloadItemStatus(PutioTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus)
{
_downloading.Status = apiStatus;
PrepareClientToReturnDownloadingItem();
var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus);
}
[TestCase(PutioTorrentStatus.Stopped, DownloadItemStatus.Completed, false)]
[TestCase(PutioTorrentStatus.CheckWait, DownloadItemStatus.Downloading, true)]
[TestCase(PutioTorrentStatus.Check, DownloadItemStatus.Downloading, true)]
[TestCase(PutioTorrentStatus.Queued, DownloadItemStatus.Completed, true)]
[TestCase(PutioTorrentStatus.SeedingWait, DownloadItemStatus.Completed, true)]
[TestCase(PutioTorrentStatus.Seeding, DownloadItemStatus.Completed, true)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(PutioTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedReadOnly)
{
_completed.Status = apiStatus;
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus);
item.IsReadOnly.Should().Be(expectedReadOnly);
}
[Test]
public void should_return_status_with_outputdirs()
{
var result = Subject.GetStatus();
result.IsLocalhost.Should().BeTrue();
result.OutputRootFolders.Should().NotBeNull();
result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Finished\Putio");
}
[Test]
public void should_fix_forward_slashes()
{
WindowsOnly();
_downloading.DownloadDir = @"C:/Downloads/Finished/Putio";
GivenTorrents(new List<PutioTorrent>
{
_downloading
});
var items = Subject.GetItems().ToList();
items.Should().HaveCount(1);
items.First().OutputPath.Should().Be(@"C:\Downloads\Finished\Putio\" + _title);
}
[TestCase(-1)] // Infinite/Unknown
[TestCase(-2)] // Magnet Downloading
public void should_ignore_negative_eta(int eta)
{
_completed.Eta = eta;
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
item.RemainingTime.Should().NotHaveValue();
}
} }
} }
*/

View File

@ -74,20 +74,21 @@ namespace NzbDrone.Core.Download.Clients.Putio
continue; continue;
} }
var item = new DownloadClientItem(); var item = new DownloadClientItem
item.DownloadId = "putio-" + torrent.Id; {
item.Category = Settings.SaveParentId; DownloadId = torrent.Id.ToString(),
item.Title = torrent.Name; Category = Settings.SaveParentId,
Title = torrent.Name,
// item.DownloadClient = Definition.Name; TotalSize = torrent.Size,
RemainingSize = torrent.Size - torrent.Downloaded,
item.TotalSize = torrent.Size; DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this)
item.RemainingSize = torrent.Size - torrent.Downloaded; };
try try
{ {
if (torrent.FileId != 0) if (torrent.FileId != 0)
{ {
/*
var file = _proxy.GetFile(torrent.FileId, Settings); var file = _proxy.GetFile(torrent.FileId, Settings);
var torrentPath = "/completed/" + file.Name; var torrentPath = "/completed/" + file.Name;
@ -103,6 +104,7 @@ namespace NzbDrone.Core.Download.Clients.Putio
} }
item.OutputPath = outputPath; // + torrent.Name; item.OutputPath = outputPath; // + torrent.Name;
*/
} }
} }
catch (DownloadClientException ex) catch (DownloadClientException ex)
@ -115,25 +117,13 @@ namespace NzbDrone.Core.Download.Clients.Putio
item.RemainingTime = TimeSpan.FromSeconds(torrent.EstimatedTime); item.RemainingTime = TimeSpan.FromSeconds(torrent.EstimatedTime);
} }
item.Status = GetStatus(torrent);
if (!torrent.ErrorMessage.IsNullOrWhiteSpace()) if (!torrent.ErrorMessage.IsNullOrWhiteSpace())
{ {
item.Status = DownloadItemStatus.Warning; item.Status = DownloadItemStatus.Warning;
item.Message = torrent.ErrorMessage; item.Message = torrent.ErrorMessage;
} }
else if (torrent.Status == PutioTorrentStatus.Completed)
{
item.Status = DownloadItemStatus.Completed;
}
else if (torrent.Status == PutioTorrentStatus.InQueue)
{
item.Status = DownloadItemStatus.Queued;
}
else
{
item.Status = DownloadItemStatus.Downloading;
}
// item.IsReadOnly = torrent.Status != PutioTorrentStatus.Error;
items.Add(item); items.Add(item);
} }
@ -141,6 +131,29 @@ namespace NzbDrone.Core.Download.Clients.Putio
return items; return items;
} }
private DownloadItemStatus GetStatus(PutioTorrent torrent)
{
if (torrent.Status == PutioTorrentStatus.Completed ||
torrent.Status == PutioTorrentStatus.Seeding)
{
return DownloadItemStatus.Completed;
}
if (torrent.Status == PutioTorrentStatus.InQueue ||
torrent.Status == PutioTorrentStatus.Waiting ||
torrent.Status == PutioTorrentStatus.PrepareDownload)
{
return DownloadItemStatus.Queued;
}
if (torrent.Status == PutioTorrentStatus.Error)
{
return DownloadItemStatus.Failed;
}
return DownloadItemStatus.Downloading;
}
public override DownloadClientInfo GetStatus() public override DownloadClientInfo GetStatus()
{ {
var destDir = string.Format("{0}", Settings.SaveParentId); var destDir = string.Format("{0}", Settings.SaveParentId);
@ -169,6 +182,14 @@ namespace NzbDrone.Core.Download.Clients.Putio
{ {
_proxy.GetAccountSettings(Settings); _proxy.GetAccountSettings(Settings);
} }
catch (DownloadClientAuthenticationException ex)
{
_logger.Error(ex, ex.Message);
return new NzbDroneValidationFailure("OAuthToken", "Authentication failed")
{
DetailedDescription = "See the wiki for more details on how to obtain an OAuthToken"
};
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex, ex.Message); _logger.Error(ex, ex.Message);

View File

@ -1,8 +1,8 @@
namespace NzbDrone.Core.Download.Clients.Putio namespace NzbDrone.Core.Download.Clients.Putio
{ {
public class PutioFile public class PutioFile
{ {
public int Id { get; set; } public long Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
} }
} }

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.Http;
using NLog; using NLog;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
namespace NzbDrone.Core.Download.Clients.Putio namespace NzbDrone.Core.Download.Clients.Putio
{ {
@ -66,48 +66,44 @@ namespace NzbDrone.Core.Download.Clients.Putio
public void GetAccountSettings(PutioSettings settings) public void GetAccountSettings(PutioSettings settings)
{ {
// ProcessRequest<PutioGenericResponse>(Method.GET, "account/settings", null, settings); // ProcessRequest<PutioGenericResponse>(Method.GET, "account/settings", null, settings);
Execute<PutioGenericResponse>(BuildRequest(HttpMethod.Get, "account/settings", settings));
} }
private HttpRequestBuilder BuildRequest(PutioSettings settings) private HttpRequestBuilder BuildRequest(HttpMethod method, string endpoint, PutioSettings settings)
{ {
var requestBuilder = new HttpRequestBuilder("https://api.put.io/v2") var requestBuilder = new HttpRequestBuilder("https://api.put.io/v2")
{ {
LogResponseContent = true LogResponseContent = true
}; };
requestBuilder.Method = method;
requestBuilder.Resource(endpoint);
requestBuilder.SetHeader("Authorization", "Bearer " + settings.OAuthToken); requestBuilder.SetHeader("Authorization", "Bearer " + settings.OAuthToken);
return requestBuilder; return requestBuilder;
} }
private string ProcessRequest(HttpRequestBuilder requestBuilder) private HttpResponse<TResult> Execute<TResult>(HttpRequestBuilder requestBuilder)
where TResult : new()
{ {
var request = requestBuilder.Build(); var request = requestBuilder.Build();
request.LogResponseContent = true; request.LogResponseContent = true;
request.SuppressHttpErrorStatusCodes = new[] { HttpStatusCode.Forbidden };
HttpResponse response;
try try
{ {
response = _httpClient.Execute(request); return _httpClient.Get<TResult>(request);
}
if (response.StatusCode == HttpStatusCode.Forbidden) catch (HttpException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
{ {
throw new DownloadClientException("Invalid credentials. Check your OAuthToken"); throw new DownloadClientAuthenticationException("Invalid credentials. Check your OAuthToken");
} }
throw new DownloadClientException("Failed to connect to put.io API", ex);
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DownloadClientException("Failed to connect to put.io.", ex); throw new DownloadClientException("Failed to connect to put.io API", ex);
} }
return response.Content;
}
private TResult ProcessRequest<TResult>(HttpRequestBuilder requestBuilder)
where TResult : new()
{
var responseContent = ProcessRequest(requestBuilder);
return Json.Deserialize<TResult>(responseContent);
} }
} }
} }

View File

@ -1,4 +1,4 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
@ -10,6 +10,7 @@ namespace NzbDrone.Core.Download.Clients.Putio
{ {
public PutioSettingsValidator() public PutioSettingsValidator()
{ {
RuleFor(c => c.OAuthToken).NotEmpty().WithMessage("Please provide an OAuth token");
RuleFor(c => c.SaveParentId).Matches(@"^\.?[0-9]*$", RegexOptions.IgnoreCase).WithMessage("Allowed characters 0-9"); RuleFor(c => c.SaveParentId).Matches(@"^\.?[0-9]*$", RegexOptions.IgnoreCase).WithMessage("Allowed characters 0-9");
} }
} }
@ -25,12 +26,15 @@ namespace NzbDrone.Core.Download.Clients.Putio
public string Url { get; } public string Url { get; }
[FieldDefinition(0, Label = "OAuth Token", Type = FieldType.Textbox)] [FieldDefinition(0, Label = "OAuth Token", Type = FieldType.Password)]
public string OAuthToken { get; set; } public string OAuthToken { get; set; }
[FieldDefinition(1, Label = "Save Parent ID", Type = FieldType.Textbox, HelpText = "Adding a save parent ID specific to Sonarr avoids conflicts with unrelated downloads, but it's optional. Creates a .[SaveParentId] subdirectory in the output directory.")] [FieldDefinition(1, Label = "Save Parent ID", Type = FieldType.Textbox, HelpText = "If you provide a folder id here the torrents will be saved in that directory")]
public string SaveParentId { get; set; } public string SaveParentId { get; set; }
[FieldDefinition(2, Label = "Disable Download", Type = FieldType.Checkbox, HelpText = "If enabled, Sonarr will not download completed files from Put.io. Useful if you manually sync with rclone or similar")]
public bool DisableDownload { get; set; }
public NzbDroneValidationResult Validate() public NzbDroneValidationResult Validate()
{ {
return new NzbDroneValidationResult(Validator.Validate(this)); return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.Putio namespace NzbDrone.Core.Download.Clients.Putio
{ {
@ -28,5 +28,10 @@ namespace NzbDrone.Core.Download.Clients.Putio
public long Size { get; set; } public long Size { get; set; }
public string Status { get; set; } public string Status { get; set; }
[JsonProperty(PropertyName = "save_parent_id")]
public long SaveParentId { get; set; }
public string Hash { get; set; }
} }
} }

View File

@ -1,10 +1,14 @@
namespace NzbDrone.Core.Download.Clients.Putio namespace NzbDrone.Core.Download.Clients.Putio
{ {
public sealed class PutioTorrentStatus public static class PutioTorrentStatus
{ {
public static readonly string Completed = "COMPLETED"; public static readonly string Waiting = "WAITING";
public static readonly string Downloading = "DOWNLOADING"; public static readonly string PrepareDownload = "PREPARING_DOWNLOAD";
public static readonly string Error = "ERROR"; public static readonly string Completed = "COMPLETED";
public static readonly string InQueue = "IN_QUEUE"; public static readonly string Completing = "COMPLETING";
public static readonly string Downloading = "DOWNLOADING";
public static readonly string Error = "ERROR";
public static readonly string InQueue = "IN_QUEUE";
public static readonly string Seeding = "SEEDING";
} }
} }