mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-19 21:44:30 -04:00
Now checking for errors before parsing newznab feeds
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Newznab
|
||||
{
|
||||
public static class NewznabPreProcessor
|
||||
{
|
||||
public static void Process(string source, string url)
|
||||
{
|
||||
var xdoc = XDocument.Parse(source);
|
||||
var error = xdoc.Descendants("error").FirstOrDefault();
|
||||
|
||||
if (error == null) return;
|
||||
|
||||
var code = Convert.ToInt32(error.Attribute("code").Value);
|
||||
|
||||
if (code >= 100 && code <= 199) throw new ApiKeyException("Invalid API key: {0}");
|
||||
|
||||
throw new NewznabException("Newznab error detected: {0}", error.Attribute("description").Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user