mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
Good riddance SyndicationFeed
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user