From 7b14da9b17c006d56f1b860c4294a60ab361a191 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 20 Jan 2012 00:18:38 -0800 Subject: [PATCH] Fixed GetQueue and GetHistory. --- NzbDrone.Core.Test/Files/History.txt | 73 +------------------ NzbDrone.Core.Test/Files/HistoryEmpty.txt | 39 +--------- .../ProviderTests/SabProviderTest.cs | 2 +- NzbDrone.Core/Providers/SabProvider.cs | 6 +- 4 files changed, 7 insertions(+), 113 deletions(-) diff --git a/NzbDrone.Core.Test/Files/History.txt b/NzbDrone.Core.Test/Files/History.txt index 1f7bc522e..92ca66eb2 100644 --- a/NzbDrone.Core.Test/Files/History.txt +++ b/NzbDrone.Core.Test/Files/History.txt @@ -1,72 +1 @@ -{ - "total_size": "40.30 GB", - "month_size": "20.23 GB", - "week_size": "5.12 GB", - "cache_limit":"-1", - "paused":true, - "new_rel_url":"", - "restart_req":false, - "slots":[ - { - "action_line":"", - "show_details":"True", - "script_log":"", - "meta":null, - "fail_message":"", - "loaded":false, - "id":605, - "size":"778.1 MB", - "category":"Apps", - "pp":"D", - "completeness":0, - "script":"", - "nzb_name":"Ubuntu.nzb", - "download_time":567, - "storage":"X:\\Apps\\Ubuntu", - "status":"Completed", - "script_line":"", - "completed":1236646078, - "nzo_id":"SABnzbd_nzo_ipet0h", - "downloaded":815878352, - "report":"000000", - "path":"Ubuntu", - "postproc_time":368, - "name":"Ubuntu", - "url":"https://newzbin.com/browse/post/000000/", - "bytes":815878352, - "url_info":"http://google.com", - "stage_log":[ - {"name":"download","actions":["Downloaded in 9 minutes 27 seconds at an average of 1404kB/s"]}, - {"name":"repair","actions":["[ubuntu] Repaired in 4 minutes 24 seconds","[ubuntu.sample] Quick Check OK"]}, - {"name":"unpack","actions":["[ubuntu] Unpacked 1 file/folder in 36 seconds"]} - ] - }], - "helpuri":"http://wiki.sabnzbd.org/", - "uptime":"12m", - "version":"trunk", - "diskspacetotal2":"503.32", - "color_scheme":"", - "darwin":false, - "nt":true, - "status":"Paused", - "last_warning":"", - "have_warnings":"0", - "cache_art":"0", - "finishaction":null, - "noofslots":516, - "cache_size":"0", - "new_release":"", - "pause_int":"0", - "mbleft":"785.89", - "diskspace2":"25.08", - "diskspace1":"25.08", - "diskspacetotal1":"503.32", - "timeleft":"0:00:00", - "mb":"785.89", - "eta":"unknown", - "nzb_quota":"", - "loadavg":"", - "kbpersec":"0.00", - "speedlimit":"0", - "webdir":"path\\to\\templates" -} \ No newline at end of file +{"history":{"active_lang":"en","paused":false,"session":"5c770e3197e4fe763423ee7c392c25d1","restart_req":false,"power_options":true,"slots":[{"action_line":"","show_details":"True","script_log":"","meta":null,"fail_message":"","loaded":false,"id":9858,"size":"970 MB","category":"tv","pp":"D","retry":0,"completeness":0,"script":"None","nzb_name":"The.Mentalist.S04E12.720p.HDTV.x264-IMMERSE.nzb","download_time":524,"storage":"C:\\ServerPool\\ServerFolders\\Unsorted TV\\The Mentalist - 4x12 - My Bloody Valentine [HDTV]","status":"Completed","script_line":"","completed":1327033479,"nzo_id":"SABnzbd_nzo_0crgis","downloaded":1016942445,"report":"","path":"D:\\SABnzbd\\downloading\\The Mentalist - 4x12 - My Bloody Valentine [HDTV]","postproc_time":24,"name":"The Mentalist - 4x12 - My Bloody Valentine [HDTV]","url":"","bytes":1016942445,"url_info":"","stage_log":[{"name":"Download","actions":["Downloaded in 8 minutes 44 seconds at an average of 1.8 MB/s"]},{"name":"Repair","actions":["[the.mentalist.s04e12.720p.hdtv.x264-immerse] Quick Check OK"]},{"name":"Unpack","actions":["[the.mentalist.s04e12.720p.hdtv.x264-immerse] Unpacked 1 files/folders in 23 seconds"]}]}],"speed":"0 ","helpuri":"http://wiki.sabnzbd.org/","size":"0 B","uptime":"1d","total_size":"10.2 T","month_size":"445.7 G","week_size":"46.6 G","version":"0.6.9","new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/sabnzbd-0.6.14","diskspacetotal2":"9314.57","color_scheme":"gold","diskspacetotal1":"871.41","nt":true,"status":"Idle","last_warning":"2012-01-19 23:58:01,736\nWARNING:\nAPI Key incorrect, Use the api key from Config->General in your 3rd party program:","have_warnings":"3","cache_art":"0","sizeleft":"0 B","finishaction":null,"paused_all":false,"cache_size":"0 B","new_release":"0.6.14","pause_int":"0","mbleft":"0.00","diskspace1":"869.82","darwin":false,"timeleft":"0:00:00","mb":"0.00","noofslots":9724,"day_size":"0 ","eta":"unknown","nzb_quota":"","loadavg":"","cache_max":"-1","kbpersec":"0.00","speedlimit":"","webdir":"D:\\SABnzbd\\SABnzbd\\interfaces\\Plush\\templates","diskspace2":"1084.96"}} \ No newline at end of file diff --git a/NzbDrone.Core.Test/Files/HistoryEmpty.txt b/NzbDrone.Core.Test/Files/HistoryEmpty.txt index 8ab8e7861..c6d22010d 100644 --- a/NzbDrone.Core.Test/Files/HistoryEmpty.txt +++ b/NzbDrone.Core.Test/Files/HistoryEmpty.txt @@ -1,38 +1 @@ -{ - "total_size": "40.30 GB", - "month_size": "20.23 GB", - "week_size": "5.12 GB", - "cache_limit":"-1", - "paused":true, - "new_rel_url":"", - "restart_req":false, - "slots":[ ], - "helpuri":"http://wiki.sabnzbd.org/", - "uptime":"12m", - "version":"trunk", - "diskspacetotal2":"503.32", - "color_scheme":"", - "darwin":false, - "nt":true, - "status":"Paused", - "last_warning":"", - "have_warnings":"0", - "cache_art":"0", - "finishaction":null, - "noofslots":516, - "cache_size":"0", - "new_release":"", - "pause_int":"0", - "mbleft":"785.89", - "diskspace2":"25.08", - "diskspace1":"25.08", - "diskspacetotal1":"503.32", - "timeleft":"0:00:00", - "mb":"785.89", - "eta":"unknown", - "nzb_quota":"", - "loadavg":"", - "kbpersec":"0.00", - "speedlimit":"0", - "webdir":"path\\to\\templates" -} \ No newline at end of file +{"history":{"active_lang":"en","paused":false,"session":"5c770e3197e4fe763423ee7c392c25d1","restart_req":false,"power_options":true,"slots":[ ],"speed":"0 ","helpuri":"http://wiki.sabnzbd.org/","size":"0 B","uptime":"1d","total_size":"10.2 T","month_size":"445.7 G","week_size":"46.6 G","version":"0.6.9","new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/sabnzbd-0.6.14","diskspacetotal2":"9314.57","color_scheme":"gold","diskspacetotal1":"871.41","nt":true,"status":"Idle","last_warning":"2012-01-19 23:58:01,736\nWARNING:\nAPI Key incorrect, Use the api key from Config->General in your 3rd party program:","have_warnings":"3","cache_art":"0","sizeleft":"0 B","finishaction":null,"paused_all":false,"cache_size":"0 B","new_release":"0.6.14","pause_int":"0","mbleft":"0.00","diskspace1":"869.82","darwin":false,"timeleft":"0:00:00","mb":"0.00","noofslots":9724,"day_size":"0 ","eta":"unknown","nzb_quota":"","loadavg":"","cache_max":"-1","kbpersec":"0.00","speedlimit":"","webdir":"D:\\SABnzbd\\SABnzbd\\interfaces\\Plush\\templates","diskspace2":"1084.96"}} \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs index 2210a0594..60dc15d2a 100644 --- a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs @@ -266,7 +266,7 @@ namespace NzbDrone.Core.Test.ProviderTests var result = Mocker.Resolve().GetQueue(); //Assert - result.Should().HaveCount(3); + result.Should().HaveCount(2); } [Test] diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index 45f932e6b..d60299475 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -5,6 +5,7 @@ using System.Text.RegularExpressions; using System.Web; using System.Xml.Linq; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Ninject; using NLog; using NzbDrone.Core.Model; @@ -90,7 +91,7 @@ namespace NzbDrone.Core.Providers CheckForError(response); - var items = JsonConvert.DeserializeObject(response).Items; + var items = JsonConvert.DeserializeObject(JObject.Parse(response).SelectToken("queue").ToString()).Items; return items ?? new List(); } @@ -102,7 +103,8 @@ namespace NzbDrone.Core.Providers CheckForError(response); - return JsonConvert.DeserializeObject(response).Items; + var items = JsonConvert.DeserializeObject(JObject.Parse(response).SelectToken("history").ToString()).Items; + return items ?? new List(); } public virtual String GetSabTitle(EpisodeParseResult parseResult)