mirror of
https://github.com/jellyfin/jellyfin-plugin-anidb.git
synced 2024-11-26 23:50:26 +00:00
Detect api errors and throw exception
This commit is contained in:
parent
170134f235
commit
7a29589b59
@ -32,6 +32,7 @@ namespace Jellyfin.Plugin.AniDB.Providers.AniDB.Metadata
|
||||
public static readonly RateLimiter RequestLimiter = new RateLimiter(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(5));
|
||||
private static readonly int[] IgnoredTagIds = { 6, 22, 23, 60, 128, 129, 185, 216, 242, 255, 268, 269, 289 };
|
||||
private static readonly Regex AniDbUrlRegex = new Regex(@"https?://anidb.net/\w+(/[0-9]+)? \[(?<name>[^\]]*)\]", RegexOptions.Compiled);
|
||||
private static readonly Regex _errorRegex = new(@"<error code=""[0-9]+"">[a-zA-Z]+</error>", RegexOptions.Compiled);
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
private readonly Dictionary<string, string> _typeMappings = new Dictionary<string, string>
|
||||
@ -578,6 +579,12 @@ namespace Jellyfin.Plugin.AniDB.Providers.AniDB.Metadata
|
||||
var text = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
text = text.Replace("�", "");
|
||||
|
||||
var errorRegexMatch = _errorRegex.Match(text);
|
||||
if (errorRegexMatch.Success)
|
||||
{
|
||||
throw new Exception("AniDB API error " + errorRegexMatch.Value);
|
||||
}
|
||||
|
||||
await writer.WriteAsync(text).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user