|
|
@ -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,34 +25,37 @@ 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 items = document.Descendants("item");
|
|
|
|
{
|
|
|
|
|
|
|
|
var document = XDocument.Load(xmlTextReader);
|
|
|
|
|
|
|
|
var items = document.Descendants("item");
|
|
|
|
|
|
|
|
|
|
|
|
var result = new List<ReportInfo>();
|
|
|
|
var result = new List<ReportInfo>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
foreach (var item in items)
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var reportInfo = ParseFeedItem(item);
|
|
|
|
try
|
|
|
|
if (reportInfo != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
reportInfo.NzbUrl = GetNzbUrl(item);
|
|
|
|
var reportInfo = ParseFeedItem(item);
|
|
|
|
reportInfo.NzbInfoUrl = GetNzbInfoUrl(item);
|
|
|
|
if (reportInfo != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
result.Add(reportInfo);
|
|
|
|
reportInfo.NzbUrl = GetNzbUrl(item);
|
|
|
|
|
|
|
|
reportInfo.NzbInfoUrl = GetNzbInfoUrl(item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Add(reportInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception itemEx)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
itemEx.Data.Add("Item", item.Title());
|
|
|
|
|
|
|
|
_logger.ErrorException("An error occurred while processing feed item from " + url, itemEx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception itemEx)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
itemEx.Data.Add("Item", item.Title());
|
|
|
|
|
|
|
|
_logger.ErrorException("An error occurred while processing feed item from " + url, itemEx);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|