YouTube worker: push status over the socket like the others (stop polling)
The date enricher was the odd one out — the dashboard polled /api/video/enrichment/youtube/status every 3s (flooding the access log) instead of using the shared WebSocket the other three workers push on. Now the existing _emit_video_enrichment_status_loop also emits 'enrichment:youtube' (same stats shape), and video-enrichment.js binds it on the socket alongside tmdb/tvdb/omdb. Removed the bespoke polling loop. One-time prime fetch on load stays (instant initial state); everything after is socket-driven. Consistent with the others.
This commit is contained in:
parent
9c3facfe7e
commit
3a24fc24b1
2 changed files with 15 additions and 13 deletions
|
|
@ -37271,6 +37271,14 @@ def _emit_video_enrichment_status_loop():
|
||||||
socketio.emit(f'enrichment:{svc}', w.get_stats())
|
socketio.emit(f'enrichment:{svc}', w.get_stats())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"Error emitting video {svc} status: {e}")
|
logger.debug(f"Error emitting video {svc} status: {e}")
|
||||||
|
# The YouTube date enricher is a standalone daemon (not an engine worker),
|
||||||
|
# but it reports the SAME stats shape — push it on the same socket so its
|
||||||
|
# dashboard orb listens like the others (no /enrichment/youtube/status poll).
|
||||||
|
try:
|
||||||
|
from core.video.youtube_enrichment import get_youtube_date_enricher
|
||||||
|
socketio.emit('enrichment:youtube', get_youtube_date_enricher().stats())
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"Error emitting video youtube status: {e}")
|
||||||
|
|
||||||
|
|
||||||
def _emit_tool_progress_loop():
|
def _emit_tool_progress_loop():
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,10 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var SERVICES = ['tmdb', 'tvdb', 'omdb']; // pushed over the shared socket
|
// All four push status over the shared socket every 2s (server emits
|
||||||
var POLLED = ['youtube']; // standalone daemon → light polling
|
// 'enrichment:<svc>') — including the standalone YouTube date enricher — so the
|
||||||
var ALL = SERVICES.concat(POLLED);
|
// browser never polls /api/video/enrichment/<svc>/status.
|
||||||
|
var SERVICES = ['tmdb', 'tvdb', 'omdb', 'youtube'];
|
||||||
|
|
||||||
function onVideoSide() {
|
function onVideoSide() {
|
||||||
return document.body.getAttribute('data-side') === 'video';
|
return document.body.getAttribute('data-side') === 'video';
|
||||||
|
|
@ -74,13 +75,7 @@
|
||||||
|
|
||||||
// One-time fetch so the buttons aren't blank until the first socket push.
|
// One-time fetch so the buttons aren't blank until the first socket push.
|
||||||
function primeOnce() {
|
function primeOnce() {
|
||||||
if (onVideoSide() && !document.hidden) ALL.forEach(pollOne);
|
if (onVideoSide() && !document.hidden) SERVICES.forEach(pollOne);
|
||||||
}
|
|
||||||
// The YouTube date enricher isn't on the socket — poll it so its orb reflects
|
|
||||||
// activity (only while the video side is foregrounded).
|
|
||||||
function pollPolledLoop() {
|
|
||||||
if (onVideoSide() && !document.hidden) POLLED.forEach(pollOne);
|
|
||||||
setTimeout(pollPolledLoop, 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen on the shared socket (set up by core.js) for the server-pushed
|
// Listen on the shared socket (set up by core.js) for the server-pushed
|
||||||
|
|
@ -112,7 +107,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
ALL.forEach(function (svc) {
|
SERVICES.forEach(function (svc) {
|
||||||
var b = btn(svc);
|
var b = btn(svc);
|
||||||
if (b) b.addEventListener('click', function () { toggle(svc); });
|
if (b) b.addEventListener('click', function () { toggle(svc); });
|
||||||
});
|
});
|
||||||
|
|
@ -123,8 +118,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
primeOnce(); // instant initial state
|
primeOnce(); // instant initial state
|
||||||
bindSocket(); // then the socket pushes updates for tmdb/tvdb/omdb
|
bindSocket(); // then the socket pushes updates for all four (incl. youtube)
|
||||||
pollPolledLoop(); // ...and poll the youtube enricher
|
|
||||||
// Re-prime when the user returns to the tab (socket kept pushing, but a
|
// Re-prime when the user returns to the tab (socket kept pushing, but a
|
||||||
// quick fetch snaps the buttons current immediately).
|
// quick fetch snaps the buttons current immediately).
|
||||||
document.addEventListener('visibilitychange', function () {
|
document.addEventListener('visibilitychange', function () {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue