From 5e3e071692db8260217c6d6aeca6079580a2e158 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 21 Jan 2012 11:36:22 -0800 Subject: [PATCH] Added a duplicated item to Queue.txt, reformated existing json sample files. --- NzbDrone.Core.Test/Files/Categories_json.txt | 26 +- NzbDrone.Core.Test/Files/History.txt | 100 +++++++- NzbDrone.Core.Test/Files/HistoryEmpty.txt | 51 +++- NzbDrone.Core.Test/Files/Queue.txt | 225 ++++++++++-------- NzbDrone.Core.Test/IndexerTests.cs | 27 +++ .../Providers/Indexer/IndexerBase.cs | 12 + 6 files changed, 337 insertions(+), 104 deletions(-) diff --git a/NzbDrone.Core.Test/Files/Categories_json.txt b/NzbDrone.Core.Test/Files/Categories_json.txt index fb2c385db..5759a90e5 100644 --- a/NzbDrone.Core.Test/Files/Categories_json.txt +++ b/NzbDrone.Core.Test/Files/Categories_json.txt @@ -1 +1,25 @@ -{"categories":["*","anime","apps","books","consoles","ds-games","emulation","games","misc","movies","music","pda","resources","test","tv","tv-dvd","unknown","wii-games","xbox-dlc","xbox-xbla","xxx"]} \ No newline at end of file +{ + "categories":[ + "*", + "anime", + "apps", + "books", + "consoles", + "ds-games", + "emulation", + "games", + "misc", + "movies", + "music", + "pda", + "resources", + "test", + "tv", + "tv-dvd", + "unknown", + "wii-games", + "xbox-dlc", + "xbox-xbla", + "xxx" + ] +} \ No newline at end of file diff --git a/NzbDrone.Core.Test/Files/History.txt b/NzbDrone.Core.Test/Files/History.txt index 92ca66eb2..118d554b8 100644 --- a/NzbDrone.Core.Test/Files/History.txt +++ b/NzbDrone.Core.Test/Files/History.txt @@ -1 +1,99 @@ -{"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 +{ + "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 c6d22010d..1c5cb9d95 100644 --- a/NzbDrone.Core.Test/Files/HistoryEmpty.txt +++ b/NzbDrone.Core.Test/Files/HistoryEmpty.txt @@ -1 +1,50 @@ -{"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 +{ + "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/Files/Queue.txt b/NzbDrone.Core.Test/Files/Queue.txt index ff84eba13..82807f829 100644 --- a/NzbDrone.Core.Test/Files/Queue.txt +++ b/NzbDrone.Core.Test/Files/Queue.txt @@ -1,103 +1,126 @@ { - "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": "Normal", - "script": "None", - "size": "267 MB", - "sizeleft": "239 MB", - "status": "Downloading", - "timeleft": "31:12:34", - "unpackopts": "3", - "verbosity": "" - }, - { - "avg_age": "580d", - "cat": "tv", - "eta": "01:45 PM Mon 23 Jan", - "filename": "The Office (US) - 1x05 - Title [WEBDL]", - "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": "" - } - ], - "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" - } + "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":"Normal", + "script":"None", + "size":"267 MB", + "sizeleft":"239 MB", + "status":"Downloading", + "timeleft":"31:12:34", + "unpackopts":"3", + "verbosity":"" + }, + { + "avg_age":"580d", + "cat":"tv", + "eta":"01:45 PM Mon 23 Jan", + "filename":"The Office (US) - 1x05 - Title [WEBDL]", + "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":"Normal", + "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" + } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index de80a91a9..a60547e2c 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -374,6 +374,33 @@ public void size_nzbsrus() parseResults[0].Size.Should().Be(1793148846); } + + [Test] + public void Server_Unavailable_503_should_not_log_exception() + { + Mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Throws(new WebException("503")); + + Mocker.Resolve().FetchRss(); + + ExceptionVerification.ExpectedErrors(0); + ExceptionVerification.ExpectedWarns(1); + } + + [Test] + public void none_503_server_error_should_still_log_error() + { + Mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Throws(new WebException("some other server error")); + + Mocker.Resolve().FetchRss(); + + ExceptionVerification.ExpectedErrors(1); + ExceptionVerification.ExpectedWarns(0); + } + [TearDown] public void TearDown() { diff --git a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs index e53ee9679..5547fa398 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs @@ -190,6 +190,18 @@ private List Fetch(IEnumerable urls) } } + catch(WebException webException) + { + if (webException.Message.Contains("503")) + { + _logger.Warn("{0} server is currently unbelievable. {1}", Name, webException.Message); + } + else + { + webException.Data.Add("FeedUrl", url); + _logger.ErrorException("An error occurred while processing feed: " + Name, webException); + } + } catch (Exception feedEx) { feedEx.Data.Add("FeedUrl", url);