Fix UpdateAuthorizationHeader method
This commit is contained in:
@@ -87,8 +87,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
set
|
||||
{
|
||||
_tubeArchivistApiKey = value;
|
||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||
Plugin.Instance?.UpdateAuthorizationHeader();
|
||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||
Plugin.Instance?.UpdateAuthorizationHeader(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
{
|
||||
// Clear existing usernames
|
||||
_jfUsernamesTo.Clear();
|
||||
|
||||
|
||||
// Split by comma, then trim each part to remove leading/trailing spaces
|
||||
foreach (var username in value.Split(','))
|
||||
{
|
||||
@@ -137,8 +137,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
_jfUsernamesTo.Add(trimmedUsername);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogDebug("Set JFUsernamesTo to: {Message}", value);
|
||||
|
||||
_logger.LogDebug("Set JFUsernamesTo to: {Message}", string.Join(", ", _jfUsernamesTo));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
handler.AllowAutoRedirect = false;
|
||||
handler.CheckCertificateRevocationList = true;
|
||||
HttpClient = new HttpClient(handler);
|
||||
|
||||
UpdateAuthorizationHeader();
|
||||
|
||||
UpdateAuthorizationHeader(Configuration.TubeArchivistApiKey);
|
||||
|
||||
SessionManager = sessionManager;
|
||||
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
||||
LibraryManager = libraryManager;
|
||||
@@ -133,12 +132,12 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
/// <summary>
|
||||
/// Updates the HTTP client's Authorization header with the current API key.
|
||||
/// </summary>
|
||||
public void UpdateAuthorizationHeader()
|
||||
/// <param name="apiKey">TubeArchivist API key.</param>
|
||||
public void UpdateAuthorizationHeader(string apiKey)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Configuration.TubeArchivistApiKey))
|
||||
if (!string.IsNullOrEmpty(apiKey))
|
||||
{
|
||||
HttpClient.DefaultRequestHeaders.Authorization =
|
||||
new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Configuration.TubeArchivistApiKey);
|
||||
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", apiKey);
|
||||
Logger.LogInformation("{Message}", "Updated Authorization header with API key");
|
||||
}
|
||||
else
|
||||
@@ -233,4 +232,4 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user