diff --git a/Jellyfin.Plugin.MediaBarEnhanced/ScriptInjector.cs b/Jellyfin.Plugin.MediaBarEnhanced/ScriptInjector.cs
index 621ace1..3aa4cd5 100644
--- a/Jellyfin.Plugin.MediaBarEnhanced/ScriptInjector.cs
+++ b/Jellyfin.Plugin.MediaBarEnhanced/ScriptInjector.cs
@@ -37,7 +37,6 @@ namespace Jellyfin.Plugin.MediaBarEnhanced
///
/// Injects the script tag into index.html if it's not already present.
///
- /// True if injection was successful or already present, false otherwise.
public void Inject()
{
try
@@ -101,6 +100,11 @@ namespace Jellyfin.Plugin.MediaBarEnhanced
_logger.LogInformation("MediaBarEnhanced script and CSS already present in index.html. Or could not be injected.");
}
}
+ catch (UnauthorizedAccessException)
+ {
+ _logger.LogWarning("Unauthorized access when attempting to inject script into index.html. Automatic injection failed. Attempting fallback now...");
+ RegisterFileTransformation();
+ }
catch (Exception ex)
{
_logger.LogError(ex, "Error injecting MediaBarEnhanced resources. Attempting fallback.");
@@ -148,8 +152,15 @@ namespace Jellyfin.Plugin.MediaBarEnhanced
{
File.WriteAllText(indexPath, content);
_logger.LogInformation("MediaBarEnhanced script removed from index.html.");
+ } else
+ {
+ _logger.LogInformation("MediaBarEnhanced script not found in index.html. No removal necessary.");
}
}
+ catch (UnauthorizedAccessException uaEx)
+ {
+ _logger.LogError(uaEx, "Unauthorized access when trying to remove MediaBarEnhanced script. Check file permissions.");
+ }
catch (Exception ex)
{
_logger.LogError(ex, "Error removing MediaBarEnhanced script.");
@@ -170,7 +181,6 @@ namespace Jellyfin.Plugin.MediaBarEnhanced
{
JObject payload = new JObject();
- // Random GUID for ID
payload.Add("id", "0dfac9d7-d898-4944-900b-1c1837707279");
payload.Add("fileNamePattern", "index.html");
payload.Add("callbackAssembly", GetType().Assembly.FullName);
@@ -221,7 +231,6 @@ namespace Jellyfin.Plugin.MediaBarEnhanced
if (pluginInterfaceType != null)
{
- // The ID must match the one used in RegisterFileTransformation
Guid id = Guid.Parse("0dfac9d7-d898-4944-900b-1c1837707279");
pluginInterfaceType.GetMethod("RemoveTransformation")?.Invoke(null, new object?[] { id });
_logger.LogInformation("File transformation unregistered successfully.");
@@ -230,7 +239,6 @@ namespace Jellyfin.Plugin.MediaBarEnhanced
}
catch (Exception ex)
{
- // Log but don't throw, as we want to continue with normal removal
_logger.LogWarning(ex, "Error attempting to unregister file transformation. It might not have been registered.");
}
}