2013-04-07 09:30:37 +02:00
|
|
|
using System;
|
|
|
|
using System.ServiceModel.Syndication;
|
|
|
|
using System.Text.RegularExpressions;
|
2013-06-08 19:29:19 +02:00
|
|
|
using NLog;
|
2013-04-15 03:41:39 +02:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-04-07 09:30:37 +02:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.NzbClub
|
|
|
|
{
|
|
|
|
public class NzbClubParser : BasicRssParser
|
|
|
|
{
|
2013-06-08 19:29:19 +02:00
|
|
|
|
|
|
|
private static readonly Regex SizeRegex = new Regex(@"(?:Size:)\s(?<size>\d+.\d+\s[g|m]i?[b])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
private readonly Logger logger;
|
|
|
|
|
|
|
|
public NzbClubParser()
|
|
|
|
{
|
|
|
|
logger = LogManager.GetCurrentClassLogger();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
protected override ReportInfo PostProcessor(SyndicationItem item, ReportInfo currentResult)
|
2013-04-07 09:30:37 +02:00
|
|
|
{
|
|
|
|
if (currentResult != null)
|
|
|
|
{
|
2013-06-08 19:29:19 +02:00
|
|
|
var match = SizeRegex.Match(item.Summary.Text);
|
|
|
|
|
|
|
|
if (match.Success && match.Groups["size"].Success)
|
|
|
|
{
|
|
|
|
currentResult.Size = GetReportSize(match.Groups["size"].Value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logger.Warn("Couldn't parse size from {0}", item.Summary.Text);
|
|
|
|
}
|
2013-04-07 09:30:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return currentResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string GetTitle(SyndicationItem syndicationItem)
|
|
|
|
{
|
2013-04-08 00:40:13 +02:00
|
|
|
var title = ParseHeader(syndicationItem.Title.Text);
|
2013-04-07 09:30:37 +02:00
|
|
|
|
|
|
|
if (String.IsNullOrWhiteSpace(title))
|
|
|
|
return syndicationItem.Title.Text;
|
|
|
|
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string GetNzbInfoUrl(SyndicationItem item)
|
|
|
|
{
|
|
|
|
return item.Links[1].Uri.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|