Add warnings to support bundle
This commit is contained in:
parent
f4e84d4d07
commit
cc01c7657d
34
ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestWarnings.cs
Normal file
34
ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestWarnings.cs
Normal file
@ -0,0 +1,34 @@
|
||||
namespace ConfusedPolarBear.Plugin.IntroSkipper.Tests;
|
||||
|
||||
using Xunit;
|
||||
|
||||
public class TestFlags
|
||||
{
|
||||
[Fact]
|
||||
public void TestEmptyFlagSerialization()
|
||||
{
|
||||
WarningManager.Clear();
|
||||
Assert.Equal("None", WarningManager.GetWarnings());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSingleFlagSerialization()
|
||||
{
|
||||
WarningManager.Clear();
|
||||
WarningManager.SetFlag(PluginWarning.UnableToAddSkipButton);
|
||||
Assert.Equal("UnableToAddSkipButton", WarningManager.GetWarnings());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDoubleFlagSerialization()
|
||||
{
|
||||
WarningManager.Clear();
|
||||
WarningManager.SetFlag(PluginWarning.UnableToAddSkipButton);
|
||||
WarningManager.SetFlag(PluginWarning.InvalidChromaprintFingerprint);
|
||||
WarningManager.SetFlag(PluginWarning.InvalidChromaprintFingerprint);
|
||||
|
||||
Assert.Equal(
|
||||
"UnableToAddSkipButton, InvalidChromaprintFingerprint",
|
||||
WarningManager.GetWarnings());
|
||||
}
|
||||
}
|
@ -78,7 +78,8 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer
|
||||
}
|
||||
catch (FingerprintException ex)
|
||||
{
|
||||
_logger.LogWarning("Caught fingerprint error: {Ex}", ex);
|
||||
_logger.LogDebug("Caught fingerprint error: {Ex}", ex);
|
||||
WarningManager.SetFlag(PluginWarning.InvalidChromaprintFingerprint);
|
||||
|
||||
// Fallback to an empty fingerprint on any error
|
||||
fingerprintCache[episode.EpisodeId] = Array.Empty<uint>();
|
||||
|
@ -58,6 +58,10 @@ public class TroubleshootingController : ControllerBase
|
||||
bundle.Append(" seasons");
|
||||
bundle.Append('\n');
|
||||
|
||||
bundle.Append("* Warnings: `");
|
||||
bundle.Append(WarningManager.GetWarnings());
|
||||
bundle.Append("`\n");
|
||||
|
||||
bundle.Append(FFmpegWrapper.GetChromaprintLogs());
|
||||
|
||||
return bundle.ToString();
|
||||
|
64
ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs
Normal file
64
ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs
Normal file
@ -0,0 +1,64 @@
|
||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Support bundle warning.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum PluginWarning
|
||||
{
|
||||
/// <summary>
|
||||
/// No warnings have been added.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Attempted to add skip button to web interface, but was unable to.
|
||||
/// </summary>
|
||||
UnableToAddSkipButton = 1,
|
||||
|
||||
/// <summary>
|
||||
/// At least one media file on the server was unable to be fingerprinted by Chromaprint.
|
||||
/// </summary>
|
||||
InvalidChromaprintFingerprint = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The version of ffmpeg installed on the system is not compatible with the plugin.
|
||||
/// </summary>
|
||||
IncompatibleFFmpegBuild = 4,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warning manager.
|
||||
/// </summary>
|
||||
public static class WarningManager
|
||||
{
|
||||
private static PluginWarning warnings;
|
||||
|
||||
/// <summary>
|
||||
/// Set warning.
|
||||
/// </summary>
|
||||
/// <param name="warning">Warning.</param>
|
||||
public static void SetFlag(PluginWarning warning)
|
||||
{
|
||||
warnings |= warning;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear warnings.
|
||||
/// </summary>
|
||||
public static void Clear()
|
||||
{
|
||||
warnings = PluginWarning.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get warnings.
|
||||
/// </summary>
|
||||
/// <returns>Warnings.</returns>
|
||||
public static string GetWarnings()
|
||||
{
|
||||
return warnings.ToString();
|
||||
}
|
||||
}
|
@ -51,6 +51,7 @@ public static class FFmpegWrapper
|
||||
"Unknown error with FFmpeg version"))
|
||||
{
|
||||
ChromaprintLogs["error"] = "unknown_error";
|
||||
WarningManager.SetFlag(PluginWarning.IncompatibleFFmpegBuild);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -62,6 +63,7 @@ public static class FFmpegWrapper
|
||||
"The installed version of ffmpeg does not support chromaprint"))
|
||||
{
|
||||
ChromaprintLogs["error"] = "chromaprint_not_supported";
|
||||
WarningManager.SetFlag(PluginWarning.IncompatibleFFmpegBuild);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -73,6 +75,7 @@ public static class FFmpegWrapper
|
||||
"The installed version of ffmpeg does not support raw binary fingerprints"))
|
||||
{
|
||||
ChromaprintLogs["error"] = "fp_format_not_supported";
|
||||
WarningManager.SetFlag(PluginWarning.IncompatibleFFmpegBuild);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -84,6 +87,7 @@ public static class FFmpegWrapper
|
||||
"The installed version of ffmpeg does not support the silencedetect filter"))
|
||||
{
|
||||
ChromaprintLogs["error"] = "silencedetect_not_supported";
|
||||
WarningManager.SetFlag(PluginWarning.IncompatibleFFmpegBuild);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -94,6 +98,7 @@ public static class FFmpegWrapper
|
||||
catch
|
||||
{
|
||||
ChromaprintLogs["error"] = "unknown_error";
|
||||
WarningManager.SetFlag(PluginWarning.IncompatibleFFmpegBuild);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// WarningManager.SetFlag(PluginWarning.UnableToAddSkipButton);
|
||||
WarningManager.SetFlag(PluginWarning.UnableToAddSkipButton);
|
||||
|
||||
if (ex is UnauthorizedAccessException)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user