2013-04-07 00:30:37 -07:00
|
|
|
using System;
|
2013-08-05 19:45:57 -07:00
|
|
|
using System.Drawing;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Xml.Linq;
|
2013-04-14 18:41:39 -07:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-04-07 00:30:37 -07:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.Newznab
|
|
|
|
{
|
|
|
|
public class NewznabParser : BasicRssParser
|
|
|
|
{
|
2013-08-05 22:06:58 -07:00
|
|
|
private static readonly XNamespace NewznabNamespace = "http://www.newznab.com/DTD/2010/feeds/attributes/";
|
2013-04-07 00:30:37 -07:00
|
|
|
|
2013-08-05 19:45:57 -07:00
|
|
|
protected override string GetNzbInfoUrl(XElement item)
|
2013-04-07 00:30:37 -07:00
|
|
|
{
|
2013-08-05 19:45:57 -07:00
|
|
|
return item.Comments().Replace("#comments", "");
|
2013-04-07 00:30:37 -07:00
|
|
|
}
|
|
|
|
|
2013-08-05 19:45:57 -07:00
|
|
|
protected override ReportInfo PostProcessor(XElement item, ReportInfo currentResult)
|
2013-04-07 00:30:37 -07:00
|
|
|
{
|
|
|
|
if (currentResult != null)
|
|
|
|
{
|
2013-08-05 22:06:58 -07:00
|
|
|
var attributes = item.Elements(NewznabNamespace + "attr");
|
2013-08-05 19:45:57 -07:00
|
|
|
var sizeElement = attributes.Single(e => e.Attribute("name").Value == "size");
|
2013-04-07 00:30:37 -07:00
|
|
|
|
2013-08-05 19:45:57 -07:00
|
|
|
currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);
|
2013-04-07 00:30:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return currentResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|