mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-17 23:41:28 +00:00
Use one stateful caption control in Jellyfin plugin
This commit is contained in:
@@ -90,9 +90,6 @@
|
||||
<button is="emby-button" type="button" id="captionNow" class="raised">
|
||||
<span>Start / resume captioning</span>
|
||||
</button>
|
||||
<button is="emby-button" type="button" id="captionPause" class="raised" disabled>
|
||||
<span>Pause</span>
|
||||
</button>
|
||||
<label class="checkboxContainer" style="margin-top:1em;">
|
||||
<input is="emby-checkbox" type="checkbox" id="forceCaption" />
|
||||
<span>Force recaption existing frames</span>
|
||||
@@ -321,7 +318,7 @@
|
||||
var container = page.querySelector('#captionStatus');
|
||||
var detail = page.querySelector('#captionDetail');
|
||||
var button = page.querySelector('#captionNow');
|
||||
var pauseButton = page.querySelector('#captionPause');
|
||||
var forceCheckbox = page.querySelector('#forceCaption');
|
||||
|
||||
if (!status) {
|
||||
progress.value = 0;
|
||||
@@ -330,8 +327,8 @@
|
||||
container.textContent = 'Caption status unavailable.';
|
||||
detail.textContent = '';
|
||||
button.disabled = false;
|
||||
pauseButton.disabled = true;
|
||||
pauseButton.querySelector('span').textContent = 'Pause';
|
||||
button.querySelector('span').textContent = 'Start / resume captioning';
|
||||
forceCheckbox.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,11 +340,12 @@
|
||||
(status.frames_total || 0) + ' frames';
|
||||
|
||||
if (status.running) {
|
||||
button.disabled = true;
|
||||
pauseButton.disabled = status.stage === 'syncing' || status.stage === 'sync';
|
||||
pauseButton.querySelector('span').textContent = status.paused
|
||||
? 'Resume'
|
||||
: (status.pause_requested ? 'Cancel pause' : 'Pause');
|
||||
var syncing = status.stage === 'syncing' || status.stage === 'sync';
|
||||
button.disabled = syncing;
|
||||
button.querySelector('span').textContent = syncing
|
||||
? 'Finishing...'
|
||||
: ((status.paused || status.pause_requested) ? 'Resume' : 'Pause');
|
||||
forceCheckbox.disabled = true;
|
||||
|
||||
if (status.paused) {
|
||||
container.textContent = 'Captioning paused.';
|
||||
@@ -378,14 +376,14 @@
|
||||
}
|
||||
} else if (status.stage === 'failed') {
|
||||
button.disabled = false;
|
||||
pauseButton.disabled = true;
|
||||
pauseButton.querySelector('span').textContent = 'Pause';
|
||||
button.querySelector('span').textContent = 'Start / resume captioning';
|
||||
forceCheckbox.disabled = false;
|
||||
container.textContent = 'Captioning failed: ' + (status.error || 'unknown error');
|
||||
detail.textContent = '';
|
||||
} else if (status.stage === 'complete') {
|
||||
button.disabled = false;
|
||||
pauseButton.disabled = true;
|
||||
pauseButton.querySelector('span').textContent = 'Pause';
|
||||
button.querySelector('span').textContent = 'Start / resume captioning';
|
||||
forceCheckbox.disabled = false;
|
||||
container.textContent =
|
||||
'Captioning complete: ' + (status.frames_completed || 0) +
|
||||
' saved, ' + (status.failed || 0) + ' failed.';
|
||||
@@ -393,8 +391,8 @@
|
||||
(status.retained || 0) + ' existing captions retained.';
|
||||
} else {
|
||||
button.disabled = false;
|
||||
pauseButton.disabled = true;
|
||||
pauseButton.querySelector('span').textContent = 'Pause';
|
||||
button.querySelector('span').textContent = 'Start / resume captioning';
|
||||
forceCheckbox.disabled = false;
|
||||
container.textContent = 'Captioning idle.';
|
||||
detail.textContent = '';
|
||||
}
|
||||
@@ -560,6 +558,28 @@
|
||||
});
|
||||
|
||||
page.querySelector('#captionNow').addEventListener('click', function () {
|
||||
if (lastCaptionStatus && lastCaptionStatus.running) {
|
||||
if (lastCaptionStatus.stage === 'syncing' || lastCaptionStatus.stage === 'sync') {
|
||||
return;
|
||||
}
|
||||
|
||||
var resume = lastCaptionStatus.paused || lastCaptionStatus.pause_requested;
|
||||
ApiClient.ajax({
|
||||
type: 'POST',
|
||||
url: ApiClient.getUrl(
|
||||
resume
|
||||
? 'Plugins/SceneSearch/CaptionResume'
|
||||
: 'Plugins/SceneSearch/CaptionPause'
|
||||
)
|
||||
}).then(function () {
|
||||
refreshCaptionStatus();
|
||||
}).catch(function () {
|
||||
page.querySelector('#captionStatus').textContent =
|
||||
'Could not change caption pause state. Check Jellyfin logs and Scene Search API status.';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var ids = selectedLibraryIds();
|
||||
if (!ids.length) {
|
||||
page.querySelector('#captionStatus').textContent = 'Select at least one library first.';
|
||||
@@ -593,27 +613,6 @@
|
||||
});
|
||||
});
|
||||
|
||||
page.querySelector('#captionPause').addEventListener('click', function () {
|
||||
if (!lastCaptionStatus || !lastCaptionStatus.running) {
|
||||
return;
|
||||
}
|
||||
|
||||
var resume = lastCaptionStatus.paused || lastCaptionStatus.pause_requested;
|
||||
ApiClient.ajax({
|
||||
type: 'POST',
|
||||
url: ApiClient.getUrl(
|
||||
resume
|
||||
? 'Plugins/SceneSearch/CaptionResume'
|
||||
: 'Plugins/SceneSearch/CaptionPause'
|
||||
)
|
||||
}).then(function () {
|
||||
refreshCaptionStatus();
|
||||
}).catch(function () {
|
||||
page.querySelector('#captionStatus').textContent =
|
||||
'Could not change caption pause state. Check Jellyfin logs and Scene Search API status.';
|
||||
});
|
||||
});
|
||||
|
||||
page.querySelector('.sceneSearchConfigForm').addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
var ids = selectedLibraryIds();
|
||||
|
||||
Reference in New Issue
Block a user