A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
refactor: remove console logging for progress and broadcast in workers
Christian Fei81e400a846d9
diff --git a/lib/workers/ffmpeg.js b/lib/workers/ffmpeg.jsindex e374479..8fa81a8 100644--- a/lib/workers/ffmpeg.js+++ b/lib/workers/ffmpeg.js@@ -57,14 +57,6 @@ function handleLine (raw, stream = 'stdout') {const currentTime = parseTime(timeRaw)const percent = duration && currentTime != null ? Math.round((currentTime / duration) * 100) : null- console.log('[ffmpeg worker] Progress:', {- frame,- fps,- currentTime,- duration,- percent- })-parentPort.postMessage({status: 'progress',frame,diff --git a/lib/workers/video.js b/lib/workers/video.jsindex 915c5d4..155b2fb 100644--- a/lib/workers/video.js+++ b/lib/workers/video.js@@ -7,7 +7,6 @@ function getOptionalCookiesPath () {if (fs.existsSync('/app/cookies.txt')) return '/app/cookies.txt'if (fs.existsSync('./cookies.txt')) return './cookies.txt'}-console.log('worker')const videoYTDLPArgs = quality => ['--concurrent-fragments','10',diff --git a/server/router/api.js b/server/router/api.jsindex ed6a7aa..4f97216 100644--- a/server/router/api.js+++ b/server/router/api.js@@ -113,24 +113,13 @@ async function downloadVideoHandler (req, res, repo, connections = [], state = {broadcastSSE(JSON.stringify({ type: 'new-videos', videos: [repo.getVideo(id)] }), connections)broadcastNewVideoOnce = true}- // Log and broadcast info/progress messages from workersif (message.status === 'info') {- console.log('[api] download info:', message.line)broadcastSSE(JSON.stringify({ type: 'download-log-line', line: message.line }), connections)}if (message.status === 'progress') {- // Ensure progress messages include the video id so the client can map updatesconst progressPayload = Object.assign({}, message)if (!progressPayload.id) progressPayload.id = id- // Add a phase marker so UI can distinguish download vs transcodeif (!progressPayload.phase) progressPayload.phase = (progressPayload.frame || (progressPayload.time && progressPayload.time.indexOf(':') >= 0 && !progressPayload.total)) ? 'transcode' : 'download'- try {- console.log('[api] download progress:', { id: progressPayload.id, percent: progressPayload.percent, time: progressPayload.time, phase: progressPayload.phase })- } catch (err) {- console.log('[api] download progress (log error)', err && err.message)- }- // Broadcast separate event types for download vs transcode so client can- // render different UI states.if (progressPayload.phase === 'transcode') {broadcastSSE(JSON.stringify({ type: 'transcode-progress', progress: progressPayload }), connections)} else {diff --git a/server/sse.js b/server/sse.jsindex 3d28ba0..2f6b4b1 100644--- a/server/sse.js+++ b/server/sse.js@@ -13,19 +13,6 @@ export function handleSSE (res, connections = []) {export function broadcastSSE (data, connections = []) {connections.forEach(connection => {if (!connection) return- // Log broadcast attempts for debugging SSE delivery- try {- const parsed = (() => {- try { return JSON.parse(data) } catch (err) { return null }- })()- if (parsed && parsed.type) {- console.log(`[sse] broadcasting type=${parsed.type} to ${connections.length} connection(s)`)- } else {- console.log('[sse] broadcasting data to', connections.length, 'connection(s)')- }- } catch (err) {- console.log('[sse] broadcast log error', err && err.message)- }const id = new Date().toISOString()connection.write('id: ' + id + '\n')