handle empty rss response from indexers.
This commit is contained in:
parent
ef32431682
commit
a22cbfee2f
|
@ -4,6 +4,7 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
@ -12,7 +13,7 @@ namespace NzbDrone.Core.Indexers
|
||||||
{
|
{
|
||||||
public interface IParseFeed
|
public interface IParseFeed
|
||||||
{
|
{
|
||||||
IEnumerable<ReportInfo> Process(Stream source, string url);
|
IEnumerable<ReportInfo> Process(string xml, string url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BasicRssParser : IParseFeed
|
public class BasicRssParser : IParseFeed
|
||||||
|
@ -24,9 +25,11 @@ namespace NzbDrone.Core.Indexers
|
||||||
_logger = LogManager.GetCurrentClassLogger();
|
_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 items = document.Descendants("item");
|
||||||
|
|
||||||
var result = new List<ReportInfo>();
|
var result = new List<ReportInfo>();
|
||||||
|
@ -53,6 +56,7 @@ namespace NzbDrone.Core.Indexers
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected virtual string GetTitle(XElement item)
|
protected virtual string GetTitle(XElement item)
|
||||||
|
|
|
@ -106,8 +106,16 @@ namespace NzbDrone.Core.Indexers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.Trace("Downloading Feed " + url);
|
_logger.Trace("Downloading Feed " + url);
|
||||||
var stream = _httpProvider.DownloadStream(url);
|
var xml = _httpProvider.DownloadString(url);
|
||||||
result.AddRange(indexer.Parser.Process(stream, url));
|
if (!string.IsNullOrWhiteSpace(xml))
|
||||||
|
{
|
||||||
|
result.AddRange(indexer.Parser.Process(xml, url));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Warn("{0} returned empty response.", url);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (WebException webException)
|
catch (WebException webException)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue