2013-04-07 10:30:37 +03:00
|
|
|
using System;
|
2013-08-06 05:45:57 +03:00
|
|
|
using System.Linq;
|
2013-09-27 07:41:08 +03:00
|
|
|
using System.Xml;
|
2013-08-06 05:45:57 +03:00
|
|
|
using System.Xml.Linq;
|
2013-09-27 07:41:08 +03:00
|
|
|
using NzbDrone.Core.Indexers.Exceptions;
|
2013-04-15 04:41:39 +03:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-04-07 10:30:37 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.Newznab
|
|
|
|
{
|
2013-09-14 02:17:58 +03:00
|
|
|
public class NewznabParser : RssParserBase
|
2013-04-07 10:30:37 +03:00
|
|
|
{
|
2013-08-06 05:45:57 +03:00
|
|
|
protected override string GetNzbInfoUrl(XElement item)
|
2013-04-07 10:30:37 +03:00
|
|
|
{
|
2013-08-06 05:45:57 +03:00
|
|
|
return item.Comments().Replace("#comments", "");
|
2013-04-07 10:30:37 +03:00
|
|
|
}
|
|
|
|
|
2013-09-14 02:17:58 +03:00
|
|
|
protected override long GetSize(XElement item)
|
2013-04-07 10:30:37 +03:00
|
|
|
{
|
2013-09-14 02:17:58 +03:00
|
|
|
var attributes = item.Elements("attr").ToList();
|
|
|
|
var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("size", StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
|
2013-09-18 03:59:40 +03:00
|
|
|
if (sizeElement != null)
|
2013-04-07 10:30:37 +03:00
|
|
|
{
|
2013-09-18 03:59:40 +03:00
|
|
|
return Convert.ToInt64(sizeElement.Attribute("value").Value);
|
2013-09-14 02:17:58 +03:00
|
|
|
}
|
2013-04-07 10:30:37 +03:00
|
|
|
|
2013-09-18 03:59:40 +03:00
|
|
|
return ParseSize(item.Description());
|
2013-09-14 02:17:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
2013-08-19 08:53:26 +03:00
|
|
|
|
|
|
|
if (rageIdElement != null)
|
|
|
|
{
|
2013-08-25 07:28:07 +03:00
|
|
|
int tvRageId;
|
|
|
|
|
|
|
|
if (Int32.TryParse(rageIdElement.Attribute("value").Value, out tvRageId))
|
|
|
|
{
|
|
|
|
currentResult.TvRageId = tvRageId;
|
|
|
|
}
|
2013-08-19 08:53:26 +03:00
|
|
|
}
|
2013-04-07 10:30:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return currentResult;
|
|
|
|
}
|
2013-09-27 07:41:08 +03:00
|
|
|
|
|
|
|
protected override void PreProcess(string source, string url)
|
|
|
|
{
|
|
|
|
NewznabPreProcessor.Process(source, url);
|
|
|
|
}
|
2013-04-07 10:30:37 +03:00
|
|
|
}
|
|
|
|
}
|