Good riddance SyndicationFeed

This commit is contained in:
Mark McDowall
2013-08-05 19:45:57 -07:00
parent 57bb37a8cd
commit 7d43afd7b9
10 changed files with 117 additions and 165 deletions
+11 -16
View File
@@ -1,11 +1,15 @@
using System;
using System.ServiceModel.Syndication;
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Newznab
{
public class NewznabParser : BasicRssParser
{
private static XNamespace NEWZNAB = "http://www.newznab.com/DTD/2010/feeds/attributes/";
private readonly Newznab _newznabIndexer;
public NewznabParser(Newznab newznabIndexer)
@@ -13,31 +17,22 @@ namespace NzbDrone.Core.Indexers.Newznab
_newznabIndexer = newznabIndexer;
}
protected override string GetNzbInfoUrl(SyndicationItem item)
protected override string GetNzbInfoUrl(XElement item)
{
return item.Id;
return item.Comments().Replace("#comments", "");
}
protected override ReportInfo PostProcessor(SyndicationItem item, ReportInfo currentResult)
protected override ReportInfo PostProcessor(XElement item, ReportInfo currentResult)
{
if (currentResult != null)
{
if (item.Links.Count > 1)
{
currentResult.Size = item.Links[1].Length;
}
var attributes = item.Elements(NEWZNAB + "attr");
var sizeElement = attributes.Single(e => e.Attribute("name").Value == "size");
currentResult.Indexer = GetName(item);
currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);
}
return currentResult;
}
private string GetName(SyndicationItem item)
{
var hostname = item.Links[0].Uri.DnsSafeHost.ToLower();
return String.Format("{0}_{1}", _newznabIndexer.Name, hostname);
}
}
}