mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-17 23:41:28 +00:00
Add stop control to web captioning
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
input[type=text],input[type=password] { width:100%; padding:11px 12px; border-radius:9px; border:1px solid #3a414d; background:#101318; color:#fff; }
|
||||
button { padding:10px 14px; border:0; border-radius:9px; cursor:pointer; background:#3b82f6; color:white; font-weight:650; }
|
||||
button.secondary { background:#303642; }
|
||||
button.danger { background:#7f1d1d; }
|
||||
button:disabled { opacity:.5; cursor:not-allowed; }
|
||||
.row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
|
||||
.between { justify-content:space-between; }
|
||||
@@ -111,6 +112,7 @@
|
||||
<div id="captionDetail" class="muted"></div>
|
||||
<div class="row" style="margin-top:14px">
|
||||
<button id="captionNow" type="button">Start / resume captioning</button>
|
||||
<button id="captionStop" type="button" class="danger" disabled>Stop</button>
|
||||
<label><input id="forceCaption" type="checkbox"> Force recaption</label>
|
||||
</div>
|
||||
</section>
|
||||
@@ -362,13 +364,20 @@
|
||||
|
||||
if (s.running) {
|
||||
const syncing = s.stage === 'syncing' || s.stage === 'sync';
|
||||
$('captionNow').disabled = syncing;
|
||||
const stopping = !!s.stop_requested;
|
||||
$('captionNow').disabled = syncing || stopping;
|
||||
$('captionNow').textContent = syncing
|
||||
? 'Finishing...'
|
||||
: ((s.paused || s.pause_requested) ? 'Resume' : 'Pause');
|
||||
: (stopping
|
||||
? 'Stopping...'
|
||||
: ((s.paused || s.pause_requested) ? 'Resume' : 'Pause'));
|
||||
$('captionStop').disabled = syncing || stopping;
|
||||
$('forceCaption').disabled = true;
|
||||
$('captionStatus').className = 'status';
|
||||
if (s.paused) {
|
||||
if (stopping) {
|
||||
$('captionStatus').textContent = 'Stop requested; finishing the current frame';
|
||||
$('captionDetail').textContent = s.title || '';
|
||||
} else if (s.paused) {
|
||||
$('captionStatus').textContent = 'Captioning paused';
|
||||
$('captionDetail').textContent =
|
||||
(s.title ? s.title + (s.timestamp_ms != null ? ' at ' + formatTs(s.timestamp_ms) : '') : '') +
|
||||
@@ -395,6 +404,7 @@
|
||||
} else if (s.stage === 'failed') {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('captionStop').disabled = true;
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status error';
|
||||
$('captionStatus').textContent = 'Failed: ' + (s.error || 'unknown error');
|
||||
@@ -402,15 +412,26 @@
|
||||
} else if (s.stage === 'complete') {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('captionStop').disabled = true;
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status ok';
|
||||
$('captionStatus').textContent =
|
||||
'Complete: ' + (s.frames_completed || 0) + ' saved, ' + (s.failed || 0) + ' failed';
|
||||
$('captionDetail').textContent =
|
||||
(s.retained || 0) + ' existing captions retained';
|
||||
} else if (s.stage === 'stopped') {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('captionStop').disabled = true;
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status muted';
|
||||
$('captionStatus').textContent = 'Stopped';
|
||||
$('captionDetail').textContent =
|
||||
(s.frames_completed || 0) + ' captions saved. Start / resume continues the remaining frames.';
|
||||
} else {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('captionStop').disabled = true;
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status muted';
|
||||
$('captionStatus').textContent = 'Idle';
|
||||
@@ -479,6 +500,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function stopCaption() {
|
||||
if (!captionLastStatus || !captionLastStatus.running) return;
|
||||
if (captionLastStatus.stage === 'syncing' || captionLastStatus.stage === 'sync') return;
|
||||
|
||||
try {
|
||||
const s = await api('/api/caption/stop', {method:'POST'});
|
||||
renderCaptionStatus(s);
|
||||
lastCaptionRunning = !!s.running;
|
||||
} catch (e) {
|
||||
$('captionStatus').className = 'status error';
|
||||
$('captionStatus').textContent = e.message;
|
||||
}
|
||||
}
|
||||
|
||||
function formatTs(ms) {
|
||||
const seconds = Math.floor((ms || 0) / 1000);
|
||||
const h = Math.floor(seconds / 3600);
|
||||
@@ -542,6 +577,7 @@
|
||||
$('applyLibraries').onclick = applyLibrarySelection;
|
||||
$('indexNow').onclick = startIndex;
|
||||
$('captionNow').onclick = captionAction;
|
||||
$('captionStop').onclick = stopCaption;
|
||||
$('reportFailed').onclick = () => loadIndexReport('failed');
|
||||
$('reportRemoved').onclick = () => loadIndexReport('removed');
|
||||
$('reportIndexed').onclick = () => loadIndexReport('indexed');
|
||||
|
||||
Reference in New Issue
Block a user