diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html
index 85a255c..cbed153 100644
--- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html
+++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html
@@ -69,6 +69,29 @@
+ Captioning
+
+ Send indexed frames from the selected libraries to the configured AI caption models. Start / resume skips frames that already have a current caption.
+
+
+
+ Start / resume captioning
+
+
+
+ Force recaption existing frames
+
+
+
+
+ 0%
+ 0 / 0 frames
+
+
+
+ Captioning idle.
+
+
Save
@@ -82,6 +105,7 @@
var page = document.querySelector('#sceneSearchConfigPage');
var currentConfig = null;
var statusTimer = null;
+ var captionTimer = null;
function selectedLibraryIds() {
return Array.prototype.slice.call(
@@ -186,6 +210,96 @@
});
}
+ function formatTs(ms) {
+ var total = Math.floor((ms || 0) / 1000);
+ var hours = Math.floor(total / 3600);
+ var minutes = Math.floor((total % 3600) / 60);
+ var seconds = total % 60;
+ return [hours, minutes, seconds].map(function (value) {
+ return String(value).padStart(2, '0');
+ }).join(':');
+ }
+
+ function renderCaptionStatus(status) {
+ var progress = page.querySelector('#captionProgress');
+ var progressText = page.querySelector('#captionProgressText');
+ var progressFrames = page.querySelector('#captionProgressFrames');
+ var container = page.querySelector('#captionStatus');
+ var detail = page.querySelector('#captionDetail');
+ var button = page.querySelector('#captionNow');
+
+ if (!status) {
+ progress.value = 0;
+ progressText.textContent = '0%';
+ progressFrames.textContent = '0 / 0 frames';
+ container.textContent = 'Caption status unavailable.';
+ detail.textContent = '';
+ button.disabled = false;
+ return;
+ }
+
+ var percent = Number(status.percent || (status.stage === 'complete' ? 100 : 0));
+ progress.value = percent;
+ progressText.textContent = percent.toFixed(1).replace('.0', '') + '%';
+ progressFrames.textContent =
+ (status.frames_completed || 0) + ' / ' +
+ (status.frames_total || 0) + ' frames';
+
+ if (status.running) {
+ button.disabled = true;
+ if (status.stage === 'routing') {
+ container.textContent = 'Routing frames to caption models.';
+ detail.textContent = (status.frames_selected || status.frames_total || 0) + ' frames selected.';
+ } else if (status.stage === 'syncing' || status.stage === 'sync') {
+ container.textContent = 'Rebuilding search index: ' + (status.documents_processed || 0);
+ detail.textContent =
+ (status.frames_completed || 0) + ' captions saved, ' +
+ (status.failed || 0) + ' failed.';
+ } else {
+ container.textContent = 'Captioning: ' +
+ (status.title || 'current frame') +
+ (status.timestamp_ms != null ? ' at ' + formatTs(status.timestamp_ms) : '');
+ detail.textContent =
+ (status.model || '') +
+ (status.route ? ', ' + status.route : '') +
+ ', ' + (status.failed || 0) + ' failed.';
+ }
+ } else if (status.stage === 'failed') {
+ button.disabled = false;
+ container.textContent = 'Captioning failed: ' + (status.error || 'unknown error');
+ detail.textContent = '';
+ } else if (status.stage === 'complete') {
+ button.disabled = false;
+ container.textContent =
+ 'Captioning complete: ' + (status.frames_completed || 0) +
+ ' saved, ' + (status.failed || 0) + ' failed.';
+ detail.textContent =
+ (status.retained || 0) + ' existing captions retained.';
+ } else {
+ button.disabled = false;
+ container.textContent = 'Captioning idle.';
+ detail.textContent = '';
+ }
+ }
+
+ function refreshCaptionStatus() {
+ return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/CaptionStatus'))
+ .then(function (status) {
+ renderCaptionStatus(status);
+ if (status && status.running) {
+ if (!captionTimer) {
+ captionTimer = setInterval(refreshCaptionStatus, 2000);
+ }
+ } else if (captionTimer) {
+ clearInterval(captionTimer);
+ captionTimer = null;
+ }
+ })
+ .catch(function () {
+ renderCaptionStatus(null);
+ });
+ }
+
function loadLibraries() {
return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/Libraries'))
.then(renderLibraries)
@@ -207,7 +321,7 @@
page.querySelector('#maxResults').value = config.MaxResults || 20;
page.querySelector('#timeoutSeconds').value = config.TimeoutSeconds || 60;
- return Promise.all([loadLibraries(), refreshStatus()]);
+ return Promise.all([loadLibraries(), refreshStatus(), refreshCaptionStatus()]);
}).finally(function () {
Dashboard.hideLoadingMsg();
});
@@ -218,6 +332,10 @@
clearInterval(statusTimer);
statusTimer = null;
}
+ if (captionTimer) {
+ clearInterval(captionTimer);
+ captionTimer = null;
+ }
});
page.querySelector('#indexNow').addEventListener('click', function () {
@@ -258,6 +376,37 @@
});
});
+ page.querySelector('#captionNow').addEventListener('click', function () {
+ var ids = selectedLibraryIds();
+ if (!ids.length) {
+ page.querySelector('#captionStatus').textContent = 'Select at least one library first.';
+ return;
+ }
+
+ page.querySelector('#captionStatus').textContent = 'Saving settings and starting captioning...';
+
+ ApiClient.getPluginConfiguration(pluginId).then(function (config) {
+ config.SelectedLibraryIds = ids;
+ currentConfig = config;
+ return ApiClient.updatePluginConfiguration(pluginId, config);
+ }).then(function () {
+ return ApiClient.ajax({
+ type: 'POST',
+ url: ApiClient.getUrl('Plugins/SceneSearch/Caption'),
+ contentType: 'application/json',
+ data: JSON.stringify({
+ library_ids: ids,
+ force: page.querySelector('#forceCaption').checked
+ })
+ });
+ }).then(function () {
+ refreshCaptionStatus();
+ }).catch(function () {
+ page.querySelector('#captionStatus').textContent =
+ 'Could not start captioning. Check Jellyfin logs and Scene Search API status.';
+ });
+ });
+
page.querySelector('.sceneSearchConfigForm').addEventListener('submit', function (event) {
event.preventDefault();
Dashboard.showLoadingMsg();