1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core/Indexers/Newznab/NewznabParser.cs
2013-09-13 16:20:35 -07:00

50 lines
1.5 KiB
C#

using System;
using System.Linq;
using System.Xml.Linq;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Newznab
{
public class NewznabParser : RssParserBase
{
protected override string GetNzbInfoUrl(XElement item)
{
return item.Comments().Replace("#comments", "");
}
protected override long GetSize(XElement item)
{
var attributes = item.Elements("attr").ToList();
var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("size", StringComparison.CurrentCultureIgnoreCase));
if (sizeElement == null)
{
}
return Convert.ToInt64(sizeElement.Attribute("value").Value);
}
protected override ReleaseInfo PostProcessor(XElement item, ReleaseInfo currentResult)
{
if (currentResult != null)
{
var attributes = item.Elements("attr").ToList();
var rageIdElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("rageid", StringComparison.CurrentCultureIgnoreCase));
if (rageIdElement != null)
{
int tvRageId;
if (Int32.TryParse(rageIdElement.Attribute("value").Value, out tvRageId))
{
currentResult.TvRageId = tvRageId;
}
}
}
return currentResult;
}
}
}