Compare commits

...

7 Commits

Author SHA1 Message Date
Taloth Saldono
0cffd851f3 Fixed: Deluge 1.3.14 API support due to changed json-rpc checks.
fixes #1738
2017-03-06 20:32:09 +01:00
Marcelo Castagna
270bc9b955 Fixed: DownloadStation interface stuck in infinite loop in some cases.
* removed empty spaces. changed dcaex => ex

* Changed error message

* changed error message

* Wrong message, ups

* Another message
2017-03-06 20:31:42 +01:00
Taloth Saldono
f7e3d9b4c2 Fixed: DownloadStation regression in queue detection. 2017-02-23 08:58:50 +01:00
Taloth Saldono
6d9a952bd1 Fixed: DownloadStation proxy failing if non-bt/nzb downloads exist. 2017-02-22 19:10:39 +01:00
margaale
3501e33722 turn task type enum into string 2017-02-22 14:10:12 -03:00
margaale
fa89d33900 Fix for key not found, returning a generic error instead 2017-02-22 14:10:12 -03:00
Mark McDowall
0af48fb2e8 Fixed: NZBGet delete:scan treated as failure
Fixes #1394
2017-02-22 00:31:51 -08:00
10 changed files with 164 additions and 81 deletions

View File

@@ -9,7 +9,7 @@ namespace NzbDrone.Common.Http
public class JsonRpcRequestBuilder : HttpRequestBuilder
{
public static HttpAccept JsonRpcHttpAccept = new HttpAccept("application/json-rpc, application/json");
public static string JsonRpcContentType = "application/json-rpc";
public static string JsonRpcContentType = "application/json";
public string JsonMethod { get; private set; }
public List<object> JsonParameters { get; private set; }

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id1",
Size = 1000,
Status = DownloadStationTaskStatus.Waiting,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id2",
Size = 1000,
Status = DownloadStationTaskStatus.Finished,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id2",
Size = 1000,
Status = DownloadStationTaskStatus.Seeding,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id3",
Size = 1000,
Status = DownloadStationTaskStatus.Downloading,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -152,7 +152,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id4",
Size = 1000,
Status = DownloadStationTaskStatus.Error,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -175,7 +175,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id5",
Size = 1000,
Status = DownloadStationTaskStatus.Seeding,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "a.mkv",
Additional = new DownloadStationTaskAdditional
@@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id6",
Size = 1000,
Status = DownloadStationTaskStatus.Seeding,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -221,7 +221,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id6",
Size = 1000,
Status = DownloadStationTaskStatus.Finished,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "a.mkv",
Additional = new DownloadStationTaskAdditional
@@ -244,7 +244,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id6",
Size = 1000,
Status = DownloadStationTaskStatus.Finished,
Type = DownloadStationTaskType.BT,
Type = DownloadStationTaskType.BT.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -304,7 +304,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_settings.TvDirectory = _tvDirectory;
}
protected virtual void GivenTorrents(List<DownloadStationTask> torrents)
protected virtual void GivenTasks(List<DownloadStationTask> torrents)
{
if (torrents == null)
{
@@ -312,13 +312,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
Mocker.GetMock<IDownloadStationProxy>()
.Setup(s => s.GetTasks(DownloadStationTaskType.BT, It.IsAny<DownloadStationSettings>()))
.Setup(s => s.GetTasks(It.IsAny<DownloadStationSettings>()))
.Returns(torrents);
}
protected void PrepareClientToReturnQueuedItem()
{
GivenTorrents(new List<DownloadStationTask>
GivenTasks(new List<DownloadStationTask>
{
_queued
});
@@ -353,7 +353,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
var tasks = new List<DownloadStationTask>() { _queued, _completed, _failed, _downloading, _seeding };
Mocker.GetMock<IDownloadStationProxy>()
.Setup(d => d.GetTasks(DownloadStationTaskType.BT, _settings))
.Setup(d => d.GetTasks(_settings))
.Returns(tasks);
return tasks.Count;
@@ -409,6 +409,28 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, It.IsAny<DownloadStationSettings>()), Times.Once());
}
[Test]
public void GetItems_should_return_empty_list_if_no_tasks_available()
{
GivenSerialNumber();
GivenSharedFolder();
GivenTasks(new List<DownloadStationTask>());
Subject.GetItems().Should().BeEmpty();
}
[Test]
public void GetItems_should_return_ignore_tasks_of_unknown_type()
{
GivenSerialNumber();
GivenSharedFolder();
GivenTasks(new List<DownloadStationTask> { _completed });
_completed.Type = "ipfs";
Subject.GetItems().Should().BeEmpty();
}
[Test]
public void GetItems_should_ignore_downloads_in_wrong_folder()
{
@@ -416,7 +438,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask> { _completed });
GivenTasks(new List<DownloadStationTask> { _completed });
Subject.GetItems().Should().BeEmpty();
}
@@ -470,7 +492,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask>() { _singleFile });
GivenTasks(new List<DownloadStationTask>() { _singleFile });
var items = Subject.GetItems();
@@ -484,7 +506,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask>() { _multipleFiles });
GivenTasks(new List<DownloadStationTask>() { _multipleFiles });
var items = Subject.GetItems();
@@ -498,7 +520,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask>() { _singleFileCompleted });
GivenTasks(new List<DownloadStationTask>() { _singleFileCompleted });
var items = Subject.GetItems();
@@ -512,7 +534,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask>() { _multipleFilesCompleted });
GivenTasks(new List<DownloadStationTask>() { _multipleFilesCompleted });
var items = Subject.GetItems();
@@ -526,7 +548,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask>
GivenTasks(new List<DownloadStationTask>
{
_queued, _downloading
});
@@ -543,7 +565,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenTorrents(new List<DownloadStationTask>
GivenTasks(new List<DownloadStationTask>
{
_completed, _failed, _seeding
});
@@ -565,7 +587,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_queued.Status = apiStatus;
GivenTorrents(new List<DownloadStationTask>() { _queued });
GivenTasks(new List<DownloadStationTask>() { _queued });
var items = Subject.GetItems();
@@ -589,7 +611,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_queued.Status = apiStatus;
GivenTorrents(new List<DownloadStationTask>() { _queued });
GivenTasks(new List<DownloadStationTask>() { _queued });
var items = Subject.GetItems();
items.Should().HaveCount(1);

View File

@@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id1",
Size = 1000,
Status = DownloadStationTaskStatus.Waiting,
Type = DownloadStationTaskType.NZB,
Type = DownloadStationTaskType.NZB.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id2",
Size = 1000,
Status = DownloadStationTaskStatus.Finished,
Type = DownloadStationTaskType.NZB,
Type = DownloadStationTaskType.NZB.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id2",
Size = 1000,
Status = DownloadStationTaskStatus.Seeding,
Type = DownloadStationTaskType.NZB,
Type = DownloadStationTaskType.NZB.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id3",
Size = 1000,
Status = DownloadStationTaskStatus.Downloading,
Type = DownloadStationTaskType.NZB,
Type = DownloadStationTaskType.NZB.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -150,7 +150,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Id = "id4",
Size = 1000,
Status = DownloadStationTaskStatus.Error,
Type = DownloadStationTaskType.NZB,
Type = DownloadStationTaskType.NZB.ToString(),
Username = "admin",
Title = "title",
Additional = new DownloadStationTaskAdditional
@@ -206,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_settings.TvDirectory = _tvDirectory;
}
protected virtual void GivenNZBs(List<DownloadStationTask> nzbs)
protected virtual void GivenTasks(List<DownloadStationTask> nzbs)
{
if (nzbs == null)
{
@@ -214,13 +214,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
Mocker.GetMock<IDownloadStationProxy>()
.Setup(s => s.GetTasks(DownloadStationTaskType.NZB, It.IsAny<DownloadStationSettings>()))
.Setup(s => s.GetTasks(It.IsAny<DownloadStationSettings>()))
.Returns(nzbs);
}
protected void PrepareClientToReturnQueuedItem()
{
GivenNZBs(new List<DownloadStationTask>
GivenTasks(new List<DownloadStationTask>
{
_queued
});
@@ -243,7 +243,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
var tasks = new List<DownloadStationTask>() { _queued, _completed, _failed, _downloading, _seeding };
Mocker.GetMock<IDownloadStationProxy>()
.Setup(d => d.GetTasks(DownloadStationTaskType.NZB, _settings))
.Setup(d => d.GetTasks(_settings))
.Returns(tasks);
}
@@ -300,11 +300,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void GetItems_should_return_empty_list_if_no_tasks_available()
{
_settings.TvDirectory = @"/shared/folder/sub";
GivenSerialNumber();
GivenSharedFolder();
GivenNZBs(new List<DownloadStationTask>());
GivenTasks(new List<DownloadStationTask>());
Subject.GetItems().Should().BeEmpty();
}
[Test]
public void GetItems_should_return_ignore_tasks_of_unknown_type()
{
GivenSerialNumber();
GivenSharedFolder();
GivenTasks(new List<DownloadStationTask> { _completed });
_completed.Type = "ipfs";
Subject.GetItems().Should().BeEmpty();
}
@@ -316,7 +326,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenNZBs(new List<DownloadStationTask> { _completed });
GivenTasks(new List<DownloadStationTask> { _completed });
Subject.GetItems().Should().BeEmpty();
}
@@ -350,7 +360,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
}
[Test]
public void Download_should_throw_and_not_add_tasks_if_cannot_get_serial_number()
public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
{
var remoteEpisode = CreateRemoteEpisode();
@@ -370,7 +380,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenNZBs(new List<DownloadStationTask>
GivenTasks(new List<DownloadStationTask>
{
_queued, _downloading
});
@@ -387,7 +397,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
GivenSerialNumber();
GivenSharedFolder();
GivenNZBs(new List<DownloadStationTask>
GivenTasks(new List<DownloadStationTask>
{
_completed, _failed, _seeding
});
@@ -408,7 +418,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_queued.Status = apiStatus;
GivenNZBs(new List<DownloadStationTask>() { _queued });
GivenTasks(new List<DownloadStationTask>() { _queued });
var items = Subject.GetItems();
@@ -431,7 +441,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
_queued.Status = apiStatus;
GivenNZBs(new List<DownloadStationTask>() { _queued });
GivenTasks(new List<DownloadStationTask>() { _queued });
var items = Subject.GetItems();
items.Should().HaveCount(1);

View File

@@ -15,8 +15,10 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public long Size { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public DownloadStationTaskType Type { get; set; }
/// <summary>
/// /// Possible values are: BT, NZB, http, ftp, eMule and https
/// </summary>
public string Type { get; set; }
[JsonProperty(PropertyName = "status_extra")]
public Dictionary<string, string> StatusExtra { get; set; }
@@ -34,7 +36,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public enum DownloadStationTaskType
{
BT, NZB, http, ftp, eMule
BT, NZB, http, ftp, eMule, https
}
public enum DownloadStationTaskStatus

View File

@@ -49,7 +49,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
if (retries == 5)
{
throw new DownloadClientException("Try to process same request more than 5 times");
throw new DownloadClientException("Try to process request to {0} with {1} more than 5 times", api, arguments.ToJson().ToString());
}
if (!_authenticated && api != DiskStationApi.Info && api != DiskStationApi.DSMInfo)
@@ -72,15 +72,21 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
}
else
{
if (responseContent.Error.SessionError)
{
_authenticated = false;
return ProcessRequest<T>(api, arguments, settings, operation, method, retries++);
}
var msg = $"Failed to {operation}. Reason: {responseContent.Error.GetMessage(api)}";
_logger.Error(msg);
if (responseContent.Error.SessionError)
{
_authenticated = false;
if (responseContent.Error.Code == 105)
{
throw new DownloadClientAuthenticationException(msg);
}
return ProcessRequest<T>(api, arguments, settings, operation, method, ++retries);
}
throw new DownloadClientException(msg);
}
}

View File

@@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
public interface IDownloadStationProxy
{
IEnumerable<DownloadStationTask> GetTasks(DownloadStationTaskType type, DownloadStationSettings settings);
IEnumerable<DownloadStationTask> GetTasks(DownloadStationSettings settings);
Dictionary<string, object> GetConfig(DownloadStationSettings settings);
void RemoveTask(string downloadId, DownloadStationSettings settings);
void AddTaskFromUrl(string url, string downloadDirectory, DownloadStationSettings settings);
@@ -40,8 +40,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
}
arguments.Add("file", new Dictionary<string, object>() { { "name", filename }, { "data", data } });
var response = ProcessRequest(DiskStationApi.DownloadStationTask, arguments, settings, $"add task from data {filename}", HttpMethod.POST);
var response = ProcessRequest(DiskStationApi.DownloadStationTask, arguments, settings, $"add task from data {filename}", HttpMethod.POST);
}
public void AddTaskFromUrl(string url, string downloadDirectory, DownloadStationSettings settings)
@@ -62,7 +62,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
var response = ProcessRequest(DiskStationApi.DownloadStationTask, arguments, settings, $"add task from url {url}");
}
public IEnumerable<DownloadStationTask> GetTasks(DownloadStationTaskType type, DownloadStationSettings settings)
public IEnumerable<DownloadStationTask> GetTasks(DownloadStationSettings settings)
{
var arguments = new Dictionary<string, object>
{
@@ -76,7 +76,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
var response = ProcessRequest<DownloadStationTaskInfoResponse>(DiskStationApi.DownloadStationTask, arguments, settings, "get tasks");
return response.Data.Tasks.Where(t => t.Type == type);
return response.Data.Tasks;
}
catch (DownloadClientException e)
{

View File

@@ -83,16 +83,23 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Responses
{
return AuthMessages[Code];
}
if (api == DiskStationApi.DownloadStationTask && DownloadStationTaskMessages.ContainsKey(Code))
{
return DownloadStationTaskMessages[Code];
}
if (api == DiskStationApi.FileStationList && FileStationMessages.ContainsKey(Code))
{
return FileStationMessages[Code];
}
return CommonMessages[Code];
if (CommonMessages.ContainsKey(Code))
{
return CommonMessages[Code];
}
return $"{ Code } - Unknown error";
}
}
}

View File

@@ -45,9 +45,14 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public override string Name => "Download Station";
protected IEnumerable<DownloadStationTask> GetTasks()
{
return _proxy.GetTasks(Settings).Where(v => v.Type.ToLower() == DownloadStationTaskType.BT.ToString().ToLower());
}
public override IEnumerable<DownloadClientItem> GetItems()
{
var torrents = _proxy.GetTasks(DownloadStationTaskType.BT, Settings);
var torrents = GetTasks();
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var items = new List<DownloadClientItem>();
@@ -145,7 +150,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
_proxy.AddTaskFromUrl(magnetLink, GetDownloadDirectory(), Settings);
var item = _proxy.GetTasks(DownloadStationTaskType.BT, Settings).SingleOrDefault(t => t.Additional.Detail["uri"] == magnetLink);
var item = GetTasks().SingleOrDefault(t => t.Additional.Detail["uri"] == magnetLink);
if (item != null)
{
@@ -164,7 +169,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
_proxy.AddTaskFromData(fileContent, filename, GetDownloadDirectory(), Settings);
var items = _proxy.GetTasks(DownloadStationTaskType.BT, Settings).Where(t => t.Additional.Detail["uri"] == Path.GetFileNameWithoutExtension(filename));
var items = GetTasks().Where(t => t.Additional.Detail["uri"] == Path.GetFileNameWithoutExtension(filename));
var item = items.SingleOrDefault();
@@ -267,7 +272,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
var downloadDir = GetDownloadDirectory();
var downloadDir = GetDefaultDir();
if (downloadDir == null)
{
return new NzbDroneValidationFailure(nameof(Settings.TvDirectory), "No default destination")
{
DetailedDescription = $"You must login into your Diskstation as {Settings.Username} and manually set it up into DownloadStation settings under BT/HTTP/FTP/NZB -> Location."
};
}
downloadDir = GetDownloadDirectory();
if (downloadDir != null)
{
@@ -280,7 +295,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{
DetailedDescription = $"The DownloadStation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
};
}
@@ -295,6 +310,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return null;
}
catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation
{
_logger.Error(ex);
return new NzbDroneValidationFailure(string.Empty, ex.Message);
}
catch (Exception ex)
{
_logger.Error(ex);
@@ -354,7 +374,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
_proxy.GetTasks(DownloadStationTaskType.BT, Settings);
GetItems();
return null;
}
catch (Exception ex)

View File

@@ -42,9 +42,14 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public override string Name => "Download Station";
protected IEnumerable<DownloadStationTask> GetTasks()
{
return _proxy.GetTasks(Settings).Where(v => v.Type.ToLower() == DownloadStationTaskType.NZB.ToString().ToLower());
}
public override IEnumerable<DownloadClientItem> GetItems()
{
var nzbTasks = _proxy.GetTasks(DownloadStationTaskType.NZB, Settings);
var nzbTasks = GetTasks();
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var items = new List<DownloadClientItem>();
@@ -158,7 +163,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
_proxy.AddTaskFromData(fileContent, filename, GetDownloadDirectory(), Settings);
var items = _proxy.GetTasks(DownloadStationTaskType.NZB, Settings).Where(t => t.Additional.Detail["uri"] == filename);
var items = GetTasks().Where(t => t.Additional.Detail["uri"] == filename);
var item = items.SingleOrDefault();
@@ -185,7 +190,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
var downloadDir = GetDownloadDirectory();
var downloadDir = GetDefaultDir();
if (downloadDir == null)
{
return new NzbDroneValidationFailure(nameof(Settings.TvDirectory), "No default destination")
{
DetailedDescription = $"You must login into your Diskstation as {Settings.Username} and manually set it up into DownloadStation settings under BT/HTTP/FTP/NZB -> Location."
};
}
downloadDir = GetDownloadDirectory();
if (downloadDir != null)
{
@@ -198,7 +213,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{
DetailedDescription = $"The DownloadStation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
};
}
@@ -213,6 +228,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return null;
}
catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation
{
_logger.Error(ex);
return new NzbDroneValidationFailure(string.Empty, ex.Message);
}
catch (Exception ex)
{
_logger.Error(ex);
@@ -353,7 +373,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
_proxy.GetTasks(DownloadStationTaskType.NZB, Settings);
GetItems();
return null;
}
catch (Exception ex)

View File

@@ -17,6 +17,8 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
public class Nzbget : UsenetClientBase<NzbgetSettings>
{
private readonly INzbgetProxy _proxy;
private readonly string[] _successStatus = { "SUCCESS", "NONE" };
private readonly string[] _deleteFailedStatus = { "HEALTH", "DUPE", "SCAN", "COPY" };
public Nzbget(INzbgetProxy proxy,
IHttpClient httpClient,
@@ -128,7 +130,6 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
}
var historyItems = new List<DownloadClientItem>();
var successStatus = new[] { "SUCCESS", "NONE" };
foreach (var item in history)
{
@@ -141,7 +142,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo);
historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir));
historyItem.Category = item.Category;
historyItem.Message = string.Format("PAR Status: {0} - Unpack Status: {1} - Move Status: {2} - Script Status: {3} - Delete Status: {4} - Mark Status: {5}", item.ParStatus, item.UnpackStatus, item.MoveStatus, item.ScriptStatus, item.DeleteStatus, item.MarkStatus);
historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}";
historyItem.Status = DownloadItemStatus.Completed;
historyItem.RemainingTime = TimeSpan.Zero;
@@ -150,7 +151,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
continue;
}
if (!successStatus.Contains(item.ParStatus))
if (!_successStatus.Contains(item.ParStatus))
{
historyItem.Status = DownloadItemStatus.Failed;
}
@@ -159,24 +160,24 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
{
historyItem.Status = DownloadItemStatus.Warning;
}
else if (!successStatus.Contains(item.UnpackStatus))
else if (!_successStatus.Contains(item.UnpackStatus))
{
historyItem.Status = DownloadItemStatus.Failed;
}
if (!successStatus.Contains(item.MoveStatus))
if (!_successStatus.Contains(item.MoveStatus))
{
historyItem.Status = DownloadItemStatus.Warning;
}
if (!successStatus.Contains(item.ScriptStatus))
if (!_successStatus.Contains(item.ScriptStatus))
{
historyItem.Status = DownloadItemStatus.Failed;
}
if (!successStatus.Contains(item.DeleteStatus) && item.DeleteStatus.IsNotNullOrWhiteSpace())
if (!_successStatus.Contains(item.DeleteStatus) && item.DeleteStatus.IsNotNullOrWhiteSpace())
{
if (item.DeleteStatus == "COPY" || item.DeleteStatus == "DUPE")
if (_deleteFailedStatus.Contains(item.DeleteStatus))
{
historyItem.Status = DownloadItemStatus.Failed;
}
@@ -186,11 +187,6 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
}
}
if (item.DeleteStatus == "HEALTH")
{
historyItem.Status = DownloadItemStatus.Failed;
}
historyItems.Add(historyItem);
}