1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-27 02:09:59 +00:00

handle empty rss response from indexers.

This commit is contained in:
kay.one 2013-08-29 18:32:25 -07:00
parent ef32431682
commit a22cbfee2f
2 changed files with 37 additions and 25 deletions

View file

@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using NLog;
using NzbDrone.Core.Parser.Model;
@ -12,7 +13,7 @@ namespace NzbDrone.Core.Indexers
{
public interface IParseFeed
{
IEnumerable<ReportInfo> Process(Stream source, string url);
IEnumerable<ReportInfo> Process(string xml, string url);
}
public class BasicRssParser : IParseFeed
@ -24,9 +25,11 @@ public BasicRssParser()
_logger = LogManager.GetCurrentClassLogger();
}
public IEnumerable<ReportInfo> Process(Stream source, string url)
public IEnumerable<ReportInfo> Process(string xml, string url)
{
var document = XDocument.Load(source);
using (var xmlTextReader = new XmlTextReader(new StringReader(xml)) { DtdProcessing = DtdProcessing.Ignore })
{
var document = XDocument.Load(xmlTextReader);
var items = document.Descendants("item");
var result = new List<ReportInfo>();
@ -53,6 +56,7 @@ public IEnumerable<ReportInfo> Process(Stream source, string url)
return result;
}
}
protected virtual string GetTitle(XElement item)

View file

@ -106,8 +106,16 @@ private List<ReportInfo> Fetch(IIndexer indexer, IEnumerable<string> urls)
try
{
_logger.Trace("Downloading Feed " + url);
var stream = _httpProvider.DownloadStream(url);
result.AddRange(indexer.Parser.Process(stream, url));
var xml = _httpProvider.DownloadString(url);
if (!string.IsNullOrWhiteSpace(xml))
{
result.AddRange(indexer.Parser.Process(xml, url));
}
else
{
_logger.Warn("{0} returned empty response.", url);
}
}
catch (WebException webException)
{