Fixed: SABnzbd queue checking will not fail when items in queue are being repaired.
SabQueue priority is parsed with a custom converter to prevent blowing up because SAB decides to use Repair as a queue priority type.
This commit is contained in:
parent
11434a347b
commit
c4b57c4a23
|
@ -0,0 +1,210 @@
|
||||||
|
{
|
||||||
|
"queue":{
|
||||||
|
"active_lang":"en",
|
||||||
|
"cache_art":"10",
|
||||||
|
"cache_max":"67108864",
|
||||||
|
"cache_size":"7 MB",
|
||||||
|
"categories":[
|
||||||
|
"*",
|
||||||
|
"apps",
|
||||||
|
"consoles",
|
||||||
|
"emp",
|
||||||
|
"movies",
|
||||||
|
"tv"
|
||||||
|
],
|
||||||
|
"color_scheme":"lightblue",
|
||||||
|
"darwin":false,
|
||||||
|
"diskspace1":"127.50",
|
||||||
|
"diskspace2":"127.50",
|
||||||
|
"diskspacetotal1":"157.76",
|
||||||
|
"diskspacetotal2":"157.76",
|
||||||
|
"eta":"01:45 PM Mon 23 Jan",
|
||||||
|
"finish":0,
|
||||||
|
"finishaction":null,
|
||||||
|
"have_warnings":"20",
|
||||||
|
"helpuri":"http://wiki.sabnzbd.org/",
|
||||||
|
"isverbose":false,
|
||||||
|
"kbpersec":"2.18",
|
||||||
|
"last_warning":"2012-01-19 23:42:39,934\nWARNING:\nAPI Key incorrect, Use the api key from Config->General in your 3rd party program:",
|
||||||
|
"limit":0,
|
||||||
|
"loadavg":"",
|
||||||
|
"mb":"686.67",
|
||||||
|
"mbleft":"657.89",
|
||||||
|
"new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/sabnzbd-0.6.14",
|
||||||
|
"new_release":"0.6.14",
|
||||||
|
"newzbinDetails":true,
|
||||||
|
"noofslots":2,
|
||||||
|
"nt":true,
|
||||||
|
"nzb_quota":"",
|
||||||
|
"pause_int":"0",
|
||||||
|
"paused":false,
|
||||||
|
"paused_all":false,
|
||||||
|
"power_options":true,
|
||||||
|
"queue_details":"0",
|
||||||
|
"refresh_rate":"20",
|
||||||
|
"restart_req":false,
|
||||||
|
"scripts":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"session":"f37dc33baec2e5566f5aec666287870d",
|
||||||
|
"size":"687 MB",
|
||||||
|
"sizeleft":"658 MB",
|
||||||
|
"slots":[
|
||||||
|
{
|
||||||
|
"avg_age":"149d",
|
||||||
|
"cat":"tv",
|
||||||
|
"eta":"06:55 AM Sat 21 Jan",
|
||||||
|
"filename":"30 Rock - 1x05 - Title [HDTV]",
|
||||||
|
"index":0,
|
||||||
|
"mb":"267.44",
|
||||||
|
"mbleft":"238.66",
|
||||||
|
"missing":0,
|
||||||
|
"msgid":6256072,
|
||||||
|
"nzo_id":"SABnzbd_nzo_qv6ilb",
|
||||||
|
"percentage":"10",
|
||||||
|
"priority":"Repair",
|
||||||
|
"script":"None",
|
||||||
|
"size":"267 MB",
|
||||||
|
"sizeleft":"239 MB",
|
||||||
|
"status":"Downloading",
|
||||||
|
"timeleft":"57:27:45",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"verbosity":""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"avg_age":"580d",
|
||||||
|
"cat":"tv",
|
||||||
|
"eta":"01:45 PM Mon 23 Jan",
|
||||||
|
"filename":"Parks and Recreation - 4x8 - Smallest Park [WEBDL]",
|
||||||
|
"index":1,
|
||||||
|
"mb":"419.23",
|
||||||
|
"mbleft":"419.23",
|
||||||
|
"missing":0,
|
||||||
|
"msgid":5657628,
|
||||||
|
"nzo_id":"SABnzbd_nzo_dgrzts",
|
||||||
|
"percentage":"0",
|
||||||
|
"priority":"Fail",
|
||||||
|
"script":"None",
|
||||||
|
"size":"419 MB",
|
||||||
|
"sizeleft":"419 MB",
|
||||||
|
"status":"Queued",
|
||||||
|
"timeleft":"86:01:55",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"verbosity":""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"avg_age":"580d",
|
||||||
|
"cat":"tv",
|
||||||
|
"eta":"01:45 PM Mon 23 Jan",
|
||||||
|
"filename":"Invalid Item",
|
||||||
|
"index":1,
|
||||||
|
"mb":"419.23",
|
||||||
|
"mbleft":"419.23",
|
||||||
|
"missing":0,
|
||||||
|
"msgid":5657628,
|
||||||
|
"nzo_id":"SABnzbd_nzo_dgrzts",
|
||||||
|
"percentage":"0",
|
||||||
|
"priority":"Normal",
|
||||||
|
"script":"None",
|
||||||
|
"size":"419 MB",
|
||||||
|
"sizeleft":"419 MB",
|
||||||
|
"status":"Queued",
|
||||||
|
"timeleft":"86:01:55",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"verbosity":""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"avg_age":"580d",
|
||||||
|
"cat":"tv",
|
||||||
|
"eta":"01:45 PM Mon 23 Jan",
|
||||||
|
"filename":"The Dailyshow - 2011-12-01 - My Episode Title [Bluray720p] [Proper]",
|
||||||
|
"index":1,
|
||||||
|
"mb":"419.23",
|
||||||
|
"mbleft":"419.23",
|
||||||
|
"missing":0,
|
||||||
|
"msgid":5657628,
|
||||||
|
"nzo_id":"SABnzbd_nzo_dgrzts",
|
||||||
|
"percentage":"0",
|
||||||
|
"priority":"Test",
|
||||||
|
"script":"None",
|
||||||
|
"size":"419 MB",
|
||||||
|
"sizeleft":"419 MB",
|
||||||
|
"status":"Queued",
|
||||||
|
"timeleft":"86:01:55",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"verbosity":""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"avg_age":"580d",
|
||||||
|
"cat":"tv",
|
||||||
|
"eta":"01:45 PM Mon 23 Jan",
|
||||||
|
"filename":"My Name is earl - Season 5 [Bluray720p]",
|
||||||
|
"index":1,
|
||||||
|
"mb":"419.23",
|
||||||
|
"mbleft":"419.23",
|
||||||
|
"missing":0,
|
||||||
|
"msgid":5657628,
|
||||||
|
"nzo_id":"SABnzbd_nzo_dgrzts",
|
||||||
|
"percentage":"0",
|
||||||
|
"priority":"Normal",
|
||||||
|
"script":"None",
|
||||||
|
"size":"419 MB",
|
||||||
|
"sizeleft":"419 MB",
|
||||||
|
"status":"Queued",
|
||||||
|
"timeleft":"86:01:55",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"verbosity":""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"avg_age":"580d",
|
||||||
|
"cat":"tv",
|
||||||
|
"eta":"01:45 PM Mon 23 Jan",
|
||||||
|
"filename":"My Name Is Earl - 3x14-3x15 - I Won't Die With a Little Help from My Friends (1) + I Won't Die With a Little Help from My Friend [Bluray720p]",
|
||||||
|
"index":1,
|
||||||
|
"mb":"419.23",
|
||||||
|
"mbleft":"419.23",
|
||||||
|
"missing":0,
|
||||||
|
"msgid":5657628,
|
||||||
|
"nzo_id":"SABnzbd_nzo_dgrzts",
|
||||||
|
"percentage":"0",
|
||||||
|
"priority":"Normal",
|
||||||
|
"script":"None",
|
||||||
|
"size":"419 MB",
|
||||||
|
"sizeleft":"419 MB",
|
||||||
|
"status":"Queued",
|
||||||
|
"timeleft":"86:01:55",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"verbosity":""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"status":"Paused",
|
||||||
|
"index":1,
|
||||||
|
"eta":"unknown",
|
||||||
|
"missing":0,
|
||||||
|
"avg_age":"1d",
|
||||||
|
"script":"None",
|
||||||
|
"msgid":"",
|
||||||
|
"verbosity":"",
|
||||||
|
"mb":"546.13",
|
||||||
|
"sizeleft":"546 MB",
|
||||||
|
"filename":"DUPLICATE / The Big Bang Theory - 5x13 - The Recombination Hypothesis [HDTV] [Proper]",
|
||||||
|
"priority":"NotReal",
|
||||||
|
"cat":"tv",
|
||||||
|
"mbleft":"546.13",
|
||||||
|
"timeleft":"0:00:00",
|
||||||
|
"percentage":"0",
|
||||||
|
"nzo_id":"SABnzbd_nzo_vayub5",
|
||||||
|
"unpackopts":"3",
|
||||||
|
"size":"546 MB"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"speed":"2 K",
|
||||||
|
"speedlimit":"2",
|
||||||
|
"start":0,
|
||||||
|
"status":"Downloading",
|
||||||
|
"timeleft":"86:01:55",
|
||||||
|
"uptime":"2d",
|
||||||
|
"version":"0.6.9",
|
||||||
|
"webdir":"C:\\Tools\\SABnzbd\\interfaces\\Classic\\templates"
|
||||||
|
}
|
||||||
|
}
|
|
@ -206,6 +206,9 @@
|
||||||
<Content Include="App_Data\Config.xml">
|
<Content Include="App_Data\Config.xml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Files\QueueUnknownPriority.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Files\LongOverview.txt">
|
<Content Include="Files\LongOverview.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -9,6 +9,7 @@ using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
|
using NzbDrone.Core.Model.Sabnzbd;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
using NzbDrone.Core.Providers.DownloadClients;
|
using NzbDrone.Core.Providers.DownloadClients;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
@ -42,7 +43,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
||||||
fakeConfig.SetupGet(c => c.SabTvCategory).Returns(cat);
|
fakeConfig.SetupGet(c => c.SabTvCategory).Returns(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void WithFullQueue()
|
private void WithFullQueue()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<HttpProvider>()
|
Mocker.GetMock<HttpProvider>()
|
||||||
|
@ -69,6 +69,16 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
||||||
.Setup(s => s.DownloadString(It.IsAny<String>())).Returns(File.ReadAllText(@".\Files\JsonError.txt"));
|
.Setup(s => s.DownloadString(It.IsAny<String>())).Returns(File.ReadAllText(@".\Files\JsonError.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WithUnknownPriorityQueue()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>()
|
||||||
|
.Setup(
|
||||||
|
s =>
|
||||||
|
s.DownloadString(
|
||||||
|
"http://192.168.5.55:2222/api?mode=queue&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\QueueUnknownPriority.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetQueue_should_return_an_empty_list_when_the_queue_is_empty()
|
public void GetQueue_should_return_an_empty_list_when_the_queue_is_empty()
|
||||||
{
|
{
|
||||||
|
@ -97,6 +107,17 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
||||||
result.Should().HaveCount(7);
|
result.Should().HaveCount(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetQueue_should_return_a_list_with_items_even_when_priority_is_non_standard()
|
||||||
|
{
|
||||||
|
WithUnknownPriorityQueue();
|
||||||
|
|
||||||
|
var result = Mocker.Resolve<SabProvider>().GetQueue();
|
||||||
|
|
||||||
|
result.Should().HaveCount(7);
|
||||||
|
result.Should().OnlyContain(i => i.Priority == SabPriorityType.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void is_in_queue_should_find_if_exact_episode_is_in_queue()
|
public void is_in_queue_should_find_if_exact_episode_is_in_queue()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NzbDrone.Core.Model.Sabnzbd;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Helpers
|
||||||
|
{
|
||||||
|
public class SabnzbdPriorityTypeConverter : JsonConverter
|
||||||
|
{
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var priorityType = (SabPriorityType)value;
|
||||||
|
writer.WriteValue(priorityType.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var queuePriority = reader.Value.ToString();
|
||||||
|
|
||||||
|
SabPriorityType output;
|
||||||
|
Enum.TryParse(queuePriority, out output);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(SabPriorityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ namespace NzbDrone.Core.Model.Sabnzbd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(SabnzbdPriorityTypeConverter))]
|
||||||
public SabPriorityType Priority { get; set; }
|
public SabPriorityType Priority { get; set; }
|
||||||
|
|
||||||
[JsonProperty(PropertyName = "cat")]
|
[JsonProperty(PropertyName = "cat")]
|
||||||
|
|
|
@ -243,6 +243,7 @@
|
||||||
<Compile Include="Datastore\Migrations\SchemaInfo.cs" />
|
<Compile Include="Datastore\Migrations\SchemaInfo.cs" />
|
||||||
<Compile Include="Datastore\PetaPoco\EpisodeSeasonRelator.cs" />
|
<Compile Include="Datastore\PetaPoco\EpisodeSeasonRelator.cs" />
|
||||||
<Compile Include="Fluent.cs" />
|
<Compile Include="Fluent.cs" />
|
||||||
|
<Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" />
|
||||||
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
||||||
<Compile Include="Helpers\SortHelper.cs" />
|
<Compile Include="Helpers\SortHelper.cs" />
|
||||||
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
|
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
|
||||||
|
|
Loading…
Reference in New Issue