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

51 lines
1.3 KiB
C#
Raw Normal View History

2016-12-23 21:45:24 +00:00
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();
2019-12-22 22:08:53 +00:00
if (notice == null)
{
return true;
}
2019-12-22 22:08:53 +00:00
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
{
2022-11-20 18:27:45 +00:00
// Todo: Me thinks I need to parse details to get this...
2019-12-22 22:08:53 +00:00
var match = Regex.Match(item.Description(),
@"(?:\<b\>View NZB\:\<\/b\>\s\<a\shref\=\"")(?<URL>.+?)(?:\"")",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
2013-04-07 07:30:37 +00:00
if (match.Success)
{
return match.Groups["URL"].Value;
}
return string.Empty;
2013-04-07 07:30:37 +00:00
}
}
2019-12-22 21:24:10 +00:00
}