Radarr/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRssParser.cs

44 lines
1.3 KiB
C#
Raw Normal View History

2013-04-07 07:30:37 +00:00
using System;
using System.Linq;
2013-04-07 07:30:37 +00:00
using System.Text.RegularExpressions;
2013-08-06 02:45:57 +00:00
using System.Xml.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers.Exceptions;
2013-04-07 07:30:37 +00:00
namespace NzbDrone.Core.Indexers.Omgwtfnzbs
{
public class OmgwtfnzbsRssParser : RssParser
2013-04-07 07:30:37 +00:00
{
public OmgwtfnzbsRssParser()
{
UseEnclosureUrl = true;
UseEnclosureLength = true;
}
protected override bool PreProcess(IndexerResponse indexerResponse)
{
var xdoc = LoadXmlDocument(indexerResponse);
var notice = xdoc.Descendants("notice").FirstOrDefault();
if (notice == null) return true;
if (!notice.Value.ContainsIgnoreCase("api")) return true;
throw new ApiKeyException(notice.Value);
}
protected override string GetInfoUrl(XElement item)
2013-04-07 07:30:37 +00:00
{
//Todo: Me thinks I need to parse details to get this...
2013-08-06 02:45:57 +00:00
var match = Regex.Match(item.Description(), @"(?:\<b\>View NZB\:\<\/b\>\s\<a\shref\=\"")(?<URL>.+)(?:\""\starget)",
2013-04-07 07:30:37 +00:00
RegexOptions.IgnoreCase | RegexOptions.Compiled);
if (match.Success)
{
return match.Groups["URL"].Value;
}
return string.Empty;
2013-04-07 07:30:37 +00:00
}
}
}