Add TA to JF sync task interval to plugin configuration

modified:   Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs
	modified:   Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html
	modified:   Jellyfin.Plugin.TubeArchivistMetadata/Tasks/TAToJellyfinProgressSyncTask.cs
This commit is contained in:
DarkFighterLuke
2024-09-06 09:38:01 +02:00
parent b07ffb2a83
commit 625b6b6958
3 changed files with 22 additions and 2 deletions
@@ -40,6 +40,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
JFUsernameFrom = string.Empty; JFUsernameFrom = string.Empty;
TAJFSync = false; TAJFSync = false;
_jfUsernamesTo = new HashSet<string>(); _jfUsernamesTo = new HashSet<string>();
TAJFTaskInterval = 1;
} }
/// <summary> /// <summary>
@@ -128,6 +129,12 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
} }
} }
/// <summary>
/// Gets or sets the interval in seconds at which the TubeArchivist to Jellyfin playback progress synchronization task should run.
/// It requires Jellyfin server restart to take effect.
/// </summary>
public int TAJFTaskInterval { get; set; }
/// <summary> /// <summary>
/// Gets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist. /// Gets the playback progress owners Jellyfin usernames to synchronize data from TubeArchivist.
/// </summary> /// </summary>
@@ -72,6 +72,13 @@
<div class="fieldDescription">These are the (comma separated) Jellyfin usernames to synchronize <div class="fieldDescription">These are the (comma separated) Jellyfin usernames to synchronize
data from TubeArchivist</div> data from TubeArchivist</div>
</div> </div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="TAJFTaskInterval">TubeArchivist to Jellyfin
playback progress synchronization interval</label>
<input id="TAJFTaskInterval" name="TAJFTaskInterval" type="number" is="emby-input" min="1" />
<div class="fieldDescription">This is the TubeArchivist to Jellyfin playback progress
synchronization interval in seconds (Jellyfin restart required).</div>
</div>
<div> <div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button"> <button is="emby-button" type="submit" class="raised button-submit block emby-button">
<span>Save</span> <span>Save</span>
@@ -97,6 +104,7 @@
document.querySelector('#JFUsernamesTo').value = config.JFUsernamesTo; document.querySelector('#JFUsernamesTo').value = config.JFUsernamesTo;
document.querySelector('#TAJFSync').checked = config.TAJFSync; document.querySelector('#TAJFSync').checked = config.TAJFSync;
document.querySelector('#JFUsernameFrom').value = config.JFUsernameFrom; document.querySelector('#JFUsernameFrom').value = config.JFUsernameFrom;
document.querySelector('#TAJFTaskInterval').value = config.TAJFTaskInterval;
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
}); });
@@ -113,6 +121,7 @@
config.JFUsernamesTo = document.querySelector('#JFUsernamesTo').value; config.JFUsernamesTo = document.querySelector('#JFUsernamesTo').value;
config.TAJFSync = document.querySelector('#TAJFSync').checked; config.TAJFSync = document.querySelector('#TAJFSync').checked;
config.JFUsernameFrom = document.querySelector('#JFUsernameFrom').value; config.JFUsernameFrom = document.querySelector('#JFUsernameFrom').value;
config.TAJFTaskInterval = document.querySelector('#TAJFTaskInterval').value;
ApiClient.updatePluginConfiguration(TAMetadataConfig.pluginUniqueId, config).then(function (result) { ApiClient.updatePluginConfiguration(TAMetadataConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result); Dashboard.processPluginConfigurationUpdateResult(result);
}); });
@@ -59,7 +59,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
if (Plugin.Instance!.Configuration.TAJFSync) if (Plugin.Instance!.Configuration.TAJFSync)
{ {
var start = DateTime.Now; var start = DateTime.Now;
_logger.LogInformation("Starting TubeArchivist playback progresses synchronization."); _logger.LogInformation("Starting TubeArchivist->Jellyfin playback progresses synchronization.");
var taApi = TubeArchivistApi.GetInstance(); var taApi = TubeArchivistApi.GetInstance();
foreach (var jfUsername in Plugin.Instance!.Configuration.GetJFUsernamesToArray()) foreach (var jfUsername in Plugin.Instance!.Configuration.GetJFUsernamesToArray())
{ {
@@ -139,6 +139,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
_logger.LogInformation("Time elapsed: {Time}", DateTime.Now - start); _logger.LogInformation("Time elapsed: {Time}", DateTime.Now - start);
} }
else
{
_logger.LogInformation("TubeArchivist->Jellyfin playback synchronization is currently disabled.");
}
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -149,7 +153,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks
new TaskTriggerInfo new TaskTriggerInfo
{ {
Type = TaskTriggerInfo.TriggerInterval, Type = TaskTriggerInfo.TriggerInterval,
IntervalTicks = TimeSpan.FromSeconds(1).Ticks IntervalTicks = TimeSpan.FromSeconds(Plugin.Instance!.Configuration.TAJFTaskInterval).Ticks
}, },
]; ];
} }