From 9a40ba93e85810cc6b345879f6ea08afba9b3379 Mon Sep 17 00:00:00 2001 From: DarkFighterLuke Date: Fri, 30 Aug 2024 10:13:32 +0200 Subject: [PATCH] Add configuration options --- .../Configuration/PluginConfiguration.cs | 72 +++++++++++ .../Configuration/configPage.html | 62 ++++++++-- .../Plugin.cs | 18 +-- .../Tasks/TAToJellyfinProgressSyncTask.cs | 115 +++++++++--------- 4 files changed, 197 insertions(+), 70 deletions(-) diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs index 4d3686a..c9c592e 100644 --- a/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs @@ -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 _jfUsernamesTo; + private HashSet _jfUsernamesFrom; /// /// Initializes a new instance of the class. @@ -33,6 +37,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration _tubeArchivistUrl = string.Empty; _tubeArchivistApiKey = string.Empty; MaxDescriptionLength = 500; + TAJFSync = false; + _jfUsernamesTo = new HashSet(); + JFTASync = false; + _jfUsernamesFrom = new HashSet(); } /// @@ -87,5 +95,69 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration /// Gets or sets maximum series and episodes overviews length. /// public int MaxDescriptionLength { get; set; } + + /// + /// Gets or sets a value indicating whether to enable TA->JF playback progress synchronization. + /// + public bool TAJFSync { get; set; } + + /// + /// Gets or sets a value indicating whether to enable JF->TA playback progress synchronization. + /// + public bool JFTASync { get; set; } + + /// + /// Gets or sets the playback progress owner Jellyfin usernames to synchronize data to TubeArchivist. + /// + 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); + } + } + + /// + /// Gets or sets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist. + /// + 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); + } + } + + /// + /// Gets the playback progress owner Jellyfin usernames to synchronize data to TubeArchivist. + /// + /// An array of usernames. + public HashSet GetJFUsernamesFromArray() + { + return _jfUsernamesFrom; + } + + /// + /// Gets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist. + /// + /// An array of usernames. + public HashSet GetJFUsernamesToArray() + { + return _jfUsernamesTo; + } } } diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html b/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html index 4c7bc20..c6a41f9 100644 --- a/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html +++ b/Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html @@ -3,7 +3,7 @@ - Template + TubeArchivistMetadata @@ -12,25 +12,65 @@
+
+

TubeArchivistMetadata

+
- +
TubeArchivist collection display name
- +
TubeArchivist URL
- +
TubeArchivist API key
- - -
This is the maximum length of the descriptions showed in series and episodes
+ + +
This is the maximum length of the descriptions showed in series + and episodes
+
+
+

Playback synchronization

+
+
+ +
+
+ + +
These are the (comma separated) Jellyfin usernames to synchronize + data from TubeArchivist
+
+
+ +
+
+ + +
These are the (comma separated) Jellyfin usernames to synchronize data from on + TubeArchivist