diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs index d639b56ef..a3a2439d9 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs @@ -16,19 +16,19 @@ public IList ParseResponse(IndexerResponse indexerResponse) { var results = new List(); - if (indexerResponse.HttpResponse.StatusCode == System.Net.HttpStatusCode.Unauthorized) + if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.Unauthorized) { throw new ApiKeyException("API Key invalid or not authorized"); } - else if (indexerResponse.HttpResponse.StatusCode == System.Net.HttpStatusCode.NotFound) + else if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound) { throw new IndexerException(indexerResponse, "Indexer API call returned NotFound, the Indexer API may have changed."); } - else if (indexerResponse.HttpResponse.StatusCode == System.Net.HttpStatusCode.ServiceUnavailable) + else if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.ServiceUnavailable) { throw new RequestLimitReachedException("Cannot do more than 150 API requests per hour."); } - else if (indexerResponse.HttpResponse.StatusCode != System.Net.HttpStatusCode.OK) + else if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); } diff --git a/src/NzbDrone.Core/Indexers/EzrssTorrentRssParser.cs b/src/NzbDrone.Core/Indexers/EzrssTorrentRssParser.cs index 8fbede813..c10331478 100644 --- a/src/NzbDrone.Core/Indexers/EzrssTorrentRssParser.cs +++ b/src/NzbDrone.Core/Indexers/EzrssTorrentRssParser.cs @@ -1,7 +1,10 @@ using System; +using System.IO; using System.Linq; +using System.Xml; using System.Xml.Linq; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Indexers.Exceptions; namespace NzbDrone.Core.Indexers { @@ -14,6 +17,22 @@ public EzrssTorrentRssParser() UseEnclosureUrl = true; } + protected override bool PreProcess(IndexerResponse indexerResponse) + { + using (var xmlTextReader = XmlReader.Create(new StringReader(indexerResponse.Content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true })) + { + var document = XDocument.Load(xmlTextReader); + var items = GetItems(document).ToList(); + + if (items.Count == 1 && GetTitle(items.First()).Equals("No items exist - Try again later")) + { + throw new IndexerException(indexerResponse, "No results were found"); + } + } + + return base.PreProcess(indexerResponse); + } + protected override Int64 GetSize(XElement item) { var contentLength = item.FindDecendants("contentLength").SingleOrDefault(); diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 7cb0b1d07..38e08ab79 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -154,7 +154,7 @@ protected virtual IList FetchReleases(IList FetchReleases(IList GetItems(XDocument document) + { + var root = document.Root; + + if (root == null) + { + return Enumerable.Empty(); + } + + var channel = root.Element("channel"); + + if (channel == null) + { + return Enumerable.Empty(); + } + + return channel.Elements("item"); + } + private static readonly Regex ParseSizeRegex = new Regex(@"(?\d+\.\d{1,2}|\d+\,\d+\.\d{1,2}|\d+)\W?(?[KMG]i?B)", RegexOptions.IgnoreCase | RegexOptions.Compiled); @@ -237,24 +255,5 @@ private static Int64 ConvertToBytes(Double value, Int32 power, Boolean binaryPre return Convert.ToInt64(result); } - - private IEnumerable GetItems(XDocument document) - { - var root = document.Root; - - if (root == null) - { - return Enumerable.Empty(); - } - - var channel = root.Element("channel"); - - if (channel == null) - { - return Enumerable.Empty(); - } - - return channel.Elements("item"); - } } } diff --git a/src/NzbDrone.Core/Indexers/TorrentRssParser.cs b/src/NzbDrone.Core/Indexers/TorrentRssParser.cs index 37d4d1ae1..14ea6eea3 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRssParser.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRssParser.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; using System.Xml.Linq; using NzbDrone.Core.Parser.Model;