Merge pull request #38 from mattkduran/master
Added new method for auth headers
This commit is contained in:
@@ -88,6 +88,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
|||||||
{
|
{
|
||||||
_tubeArchivistApiKey = value;
|
_tubeArchivistApiKey = value;
|
||||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||||
|
Plugin.Instance?.UpdateAuthorizationHeader(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,8 +125,20 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
|||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
value.Replace(" ", string.Empty, StringComparison.CurrentCulture).Split(',').ToList().ForEach(u => _jfUsernamesTo.Add(u));
|
// Clear existing usernames
|
||||||
_logger.LogDebug("Set JFUsernamesTo to: {Message}", value);
|
_jfUsernamesTo.Clear();
|
||||||
|
|
||||||
|
// Split by comma, then trim each part to remove leading/trailing spaces
|
||||||
|
foreach (var username in value.Split(','))
|
||||||
|
{
|
||||||
|
var trimmedUsername = username.Trim();
|
||||||
|
if (!string.IsNullOrEmpty(trimmedUsername))
|
||||||
|
{
|
||||||
|
_jfUsernamesTo.Add(trimmedUsername);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Set JFUsernamesTo to: {Message}", string.Join(", ", _jfUsernamesTo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
handler.AllowAutoRedirect = false;
|
handler.AllowAutoRedirect = false;
|
||||||
handler.CheckCertificateRevocationList = true;
|
handler.CheckCertificateRevocationList = true;
|
||||||
HttpClient = new HttpClient(handler);
|
HttpClient = new HttpClient(handler);
|
||||||
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Instance?.Configuration.TubeArchivistApiKey);
|
UpdateAuthorizationHeader(Configuration.TubeArchivistApiKey);
|
||||||
|
|
||||||
SessionManager = sessionManager;
|
SessionManager = sessionManager;
|
||||||
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
||||||
LibraryManager = libraryManager;
|
LibraryManager = libraryManager;
|
||||||
@@ -128,6 +129,23 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the HTTP client's Authorization header with the current API key.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="apiKey">TubeArchivist API key.</param>
|
||||||
|
public void UpdateAuthorizationHeader(string apiKey)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(apiKey))
|
||||||
|
{
|
||||||
|
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", apiKey);
|
||||||
|
Logger.LogInformation("{Message}", "Updated Authorization header with API key");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogWarning("{Message}", "No TubeArchivist API key configured");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logs the TubeArchivist API connection status.
|
/// Logs the TubeArchivist API connection status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user