Add configuration options

This commit is contained in:
DarkFighterLuke
2024-08-30 10:13:32 +02:00
parent fd4a9a0130
commit 9a40ba93e8
4 changed files with 197 additions and 70 deletions
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
using MediaBrowser.Model.Plugins;
using Microsoft.Extensions.Logging;
@@ -14,6 +16,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
private ILogger _logger;
private string _tubeArchivistUrl;
private string _tubeArchivistApiKey;
private HashSet<string> _jfUsernamesTo;
private HashSet<string> _jfUsernamesFrom;
/// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
@@ -33,6 +37,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
_tubeArchivistUrl = string.Empty;
_tubeArchivistApiKey = string.Empty;
MaxDescriptionLength = 500;
TAJFSync = false;
_jfUsernamesTo = new HashSet<string>();
JFTASync = false;
_jfUsernamesFrom = new HashSet<string>();
}
/// <summary>
@@ -87,5 +95,69 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
/// Gets or sets maximum series and episodes overviews length.
/// </summary>
public int MaxDescriptionLength { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable TA->JF playback progress synchronization.
/// </summary>
public bool TAJFSync { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable JF->TA playback progress synchronization.
/// </summary>
public bool JFTASync { get; set; }
/// <summary>
/// Gets or sets the playback progress owner Jellyfin usernames to synchronize data to TubeArchivist.
/// </summary>
public string JFUsernamesFrom
{
get
{
_logger.LogInformation("JFUsernamesFrom configured: {Message}", string.Join(", ", _jfUsernamesFrom));
return string.Join(", ", _jfUsernamesFrom);
}
set
{
value.Replace(" ", string.Empty, StringComparison.CurrentCulture).Split(',').ToList().ForEach(u => _jfUsernamesFrom.Add(u));
_logger.LogInformation("Set JFUsernamesFrom to: {Message}", value);
}
}
/// <summary>
/// Gets or sets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist.
/// </summary>
public string JFUsernamesTo
{
get
{
_logger.LogInformation("JFUsernamesTo configured: {Message}", string.Join(", ", _jfUsernamesTo));
return string.Join(", ", _jfUsernamesTo);
}
set
{
value.Replace(" ", string.Empty, StringComparison.CurrentCulture).Split(',').ToList().ForEach(u => _jfUsernamesTo.Add(u));
_logger.LogInformation("Set JFUsernamesTo to: {Message}", value);
}
}
/// <summary>
/// Gets the playback progress owner Jellyfin usernames to synchronize data to TubeArchivist.
/// </summary>
/// <returns>An array of usernames.</returns>
public HashSet<string> GetJFUsernamesFromArray()
{
return _jfUsernamesFrom;
}
/// <summary>
/// Gets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist.
/// </summary>
/// <returns>An array of usernames.</returns>
public HashSet<string> GetJFUsernamesToArray()
{
return _jfUsernamesTo;
}
}
}