cleanup and organize

This commit is contained in:
Kilian von Pflugk 2024-09-21 18:35:10 +02:00
parent 2e092543f5
commit 002f82d6e6
10 changed files with 19 additions and 30 deletions

View File

@ -24,4 +24,8 @@
<EmbeddedResource Include="Configuration\inject.js" /> <EmbeddedResource Include="Configuration\inject.js" />
<EmbeddedResource Include="Configuration\version.txt" /> <EmbeddedResource Include="Configuration\version.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Manager\" />
<Folder Include="Services\" />
</ItemGroup>
</Project> </Project>

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Net.Mime; using System.Net.Mime;
using System.Text; using System.Text;
using ConfusedPolarBear.Plugin.IntroSkipper.Data; using ConfusedPolarBear.Plugin.IntroSkipper.Data;
using ConfusedPolarBear.Plugin.IntroSkipper.Helper;
using MediaBrowser.Common; using MediaBrowser.Common;
using MediaBrowser.Common.Api; using MediaBrowser.Common.Api;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -63,7 +64,7 @@ public class TroubleshootingController : ControllerBase
try try
{ {
var commit = Plugin.Instance.GetCommit(); var commit = Commit.CommitHash;
if (!string.IsNullOrWhiteSpace(commit)) if (!string.IsNullOrWhiteSpace(commit))
{ {
version += string.Concat("+", commit.AsSpan(0, 12)); version += string.Concat("+", commit.AsSpan(0, 12));

View File

@ -0,0 +1,13 @@
namespace ConfusedPolarBear.Plugin.IntroSkipper.Helper
{
/// <summary>
/// Gets the commit used to build the plugin.
/// </summary>
public static class Commit
{
/// <summary>
/// Gets the commit hash used to build the plugin.
/// </summary>
public static string CommitHash => string.Empty;
}
}

View File

@ -340,35 +340,6 @@ public partial class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
]; ];
} }
/// <summary>
/// Gets the commit used to build the plugin.
/// </summary>
/// <returns>Commit.</returns>
public string GetCommit()
{
var commit = string.Empty;
var path = GetType().Namespace + ".Configuration.version.txt";
using var stream = GetType().Assembly.GetManifestResourceStream(path);
if (stream is null)
{
_logger.LogWarning("Unable to read embedded version information");
return commit;
}
using var reader = new StreamReader(stream);
commit = reader.ReadToEnd().TrimEnd();
if (commit == "unknown")
{
_logger.LogTrace("Embedded version information was not valid, ignoring");
return string.Empty;
}
_logger.LogInformation("Unstable plugin version built from commit {Commit}", commit);
return commit;
}
/// <summary> /// <summary>
/// Gets the Intro for this item. /// Gets the Intro for this item.
/// </summary> /// </summary>