mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-20 00:33:36 +00:00
Add pause and resume controls to web captioning
This commit is contained in:
@@ -101,6 +101,7 @@
|
|||||||
<div id="captionDetail" class="muted"></div>
|
<div id="captionDetail" class="muted"></div>
|
||||||
<div class="row" style="margin-top:14px">
|
<div class="row" style="margin-top:14px">
|
||||||
<button id="captionNow" type="button">Start / resume captioning</button>
|
<button id="captionNow" type="button">Start / resume captioning</button>
|
||||||
|
<button id="captionPause" type="button" class="secondary" disabled>Pause</button>
|
||||||
<label><input id="forceCaption" type="checkbox"> Force recaption</label>
|
<label><input id="forceCaption" type="checkbox"> Force recaption</label>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -121,6 +122,7 @@
|
|||||||
const $ = id => document.getElementById(id);
|
const $ = id => document.getElementById(id);
|
||||||
let statusTimer = null;
|
let statusTimer = null;
|
||||||
let captionTimer = null;
|
let captionTimer = null;
|
||||||
|
let captionLastStatus = null;
|
||||||
let thumbnailUrls = [];
|
let thumbnailUrls = [];
|
||||||
|
|
||||||
$('apiKey').value = localStorage.getItem('sceneSearchApiKey') || '';
|
$('apiKey').value = localStorage.getItem('sceneSearchApiKey') || '';
|
||||||
@@ -255,6 +257,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderCaptionStatus(s) {
|
function renderCaptionStatus(s) {
|
||||||
|
captionLastStatus = s;
|
||||||
const percent = Number(s.percent || (s.stage === 'complete' ? 100 : 0));
|
const percent = Number(s.percent || (s.stage === 'complete' ? 100 : 0));
|
||||||
$('captionProgress').value = percent;
|
$('captionProgress').value = percent;
|
||||||
$('captionText').textContent = percent.toFixed(1).replace('.0','') + '%';
|
$('captionText').textContent = percent.toFixed(1).replace('.0','') + '%';
|
||||||
@@ -262,8 +265,20 @@
|
|||||||
|
|
||||||
if (s.running) {
|
if (s.running) {
|
||||||
$('captionNow').disabled = true;
|
$('captionNow').disabled = true;
|
||||||
|
$('captionPause').disabled = s.stage === 'syncing' || s.stage === 'sync';
|
||||||
|
$('captionPause').textContent = s.paused
|
||||||
|
? 'Resume'
|
||||||
|
: (s.pause_requested ? 'Cancel pause' : 'Pause');
|
||||||
$('captionStatus').className = 'status';
|
$('captionStatus').className = 'status';
|
||||||
if (s.stage === 'routing') {
|
if (s.paused) {
|
||||||
|
$('captionStatus').textContent = 'Captioning paused';
|
||||||
|
$('captionDetail').textContent =
|
||||||
|
(s.title ? s.title + (s.timestamp_ms != null ? ' at ' + formatTs(s.timestamp_ms) : '') : '') +
|
||||||
|
(s.frames_completed != null ? ' · ' + s.frames_completed + '/' + (s.frames_total || 0) + ' frames saved' : '');
|
||||||
|
} else if (s.pause_requested) {
|
||||||
|
$('captionStatus').textContent = 'Pause requested; finishing the current frame';
|
||||||
|
$('captionDetail').textContent = s.title || '';
|
||||||
|
} else if (s.stage === 'routing') {
|
||||||
$('captionStatus').textContent = 'Routing frames to caption models';
|
$('captionStatus').textContent = 'Routing frames to caption models';
|
||||||
$('captionDetail').textContent = (s.frames_selected || s.frames_total || 0) + ' frames selected';
|
$('captionDetail').textContent = (s.frames_selected || s.frames_total || 0) + ' frames selected';
|
||||||
} else if (s.stage === 'syncing' || s.stage === 'sync') {
|
} else if (s.stage === 'syncing' || s.stage === 'sync') {
|
||||||
@@ -281,11 +296,15 @@
|
|||||||
}
|
}
|
||||||
} else if (s.stage === 'failed') {
|
} else if (s.stage === 'failed') {
|
||||||
$('captionNow').disabled = false;
|
$('captionNow').disabled = false;
|
||||||
|
$('captionPause').disabled = true;
|
||||||
|
$('captionPause').textContent = 'Pause';
|
||||||
$('captionStatus').className = 'status error';
|
$('captionStatus').className = 'status error';
|
||||||
$('captionStatus').textContent = 'Failed: ' + (s.error || 'unknown error');
|
$('captionStatus').textContent = 'Failed: ' + (s.error || 'unknown error');
|
||||||
$('captionDetail').textContent = '';
|
$('captionDetail').textContent = '';
|
||||||
} else if (s.stage === 'complete') {
|
} else if (s.stage === 'complete') {
|
||||||
$('captionNow').disabled = false;
|
$('captionNow').disabled = false;
|
||||||
|
$('captionPause').disabled = true;
|
||||||
|
$('captionPause').textContent = 'Pause';
|
||||||
$('captionStatus').className = 'status ok';
|
$('captionStatus').className = 'status ok';
|
||||||
$('captionStatus').textContent =
|
$('captionStatus').textContent =
|
||||||
'Complete: ' + (s.frames_completed || 0) + ' saved, ' + (s.failed || 0) + ' failed';
|
'Complete: ' + (s.frames_completed || 0) + ' saved, ' + (s.failed || 0) + ' failed';
|
||||||
@@ -293,6 +312,8 @@
|
|||||||
(s.retained || 0) + ' existing captions retained';
|
(s.retained || 0) + ' existing captions retained';
|
||||||
} else {
|
} else {
|
||||||
$('captionNow').disabled = false;
|
$('captionNow').disabled = false;
|
||||||
|
$('captionPause').disabled = true;
|
||||||
|
$('captionPause').textContent = 'Pause';
|
||||||
$('captionStatus').className = 'status muted';
|
$('captionStatus').className = 'status muted';
|
||||||
$('captionStatus').textContent = 'Idle';
|
$('captionStatus').textContent = 'Idle';
|
||||||
$('captionDetail').textContent = '';
|
$('captionDetail').textContent = '';
|
||||||
@@ -338,6 +359,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toggleCaptionPause() {
|
||||||
|
if (!captionLastStatus || !captionLastStatus.running) return;
|
||||||
|
const resume = captionLastStatus.paused || captionLastStatus.pause_requested;
|
||||||
|
try {
|
||||||
|
const s = await api(resume ? '/api/caption/resume' : '/api/caption/pause', {
|
||||||
|
method:'POST'
|
||||||
|
});
|
||||||
|
renderCaptionStatus(s);
|
||||||
|
} catch (e) {
|
||||||
|
$('captionStatus').className = 'status error';
|
||||||
|
$('captionStatus').textContent = e.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function formatTs(ms) {
|
function formatTs(ms) {
|
||||||
const seconds = Math.floor((ms || 0) / 1000);
|
const seconds = Math.floor((ms || 0) / 1000);
|
||||||
const h = Math.floor(seconds / 3600);
|
const h = Math.floor(seconds / 3600);
|
||||||
@@ -400,6 +435,7 @@
|
|||||||
$('selectAll').onclick = () => document.querySelectorAll('.libraryCheck').forEach(x => x.checked = true);
|
$('selectAll').onclick = () => document.querySelectorAll('.libraryCheck').forEach(x => x.checked = true);
|
||||||
$('indexNow').onclick = startIndex;
|
$('indexNow').onclick = startIndex;
|
||||||
$('captionNow').onclick = startCaption;
|
$('captionNow').onclick = startCaption;
|
||||||
|
$('captionPause').onclick = toggleCaptionPause;
|
||||||
$('searchButton').onclick = search;
|
$('searchButton').onclick = search;
|
||||||
$('searchQuery').addEventListener('keydown', e => { if (e.key === 'Enter') search(); });
|
$('searchQuery').addEventListener('keydown', e => { if (e.key === 'Enter') search(); });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user