Compare commits

...

2 Commits

Author SHA1 Message Date
62f1b5965e Update Handoff: progress display fix recorded
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DfhCF3fAgZyDN9BUsEyNFd
2026-08-31 08:58:23 +02:00
8a86500e80 Collapse yt-dlp progress updates into a single updating log line
yt-dlp rewrites its progress line in place via carriage return; the SSE
stream forwarded every update as a separate log entry, so the UI piled
up hundreds of near-identical boxes. Progress lines (yt-dlp download
stats, ffmpeg frame/size lines) are now tagged as their own event type
and the client replaces the previous progress entry instead of
appending. The line splitter also splits on bare \r.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DfhCF3fAgZyDN9BUsEyNFd
2026-08-31 08:57:56 +02:00
3 changed files with 40 additions and 8 deletions

View File

@ -1,15 +1,18 @@
# yt-dlf — Handoff # yt-dlf — Handoff
> Übergabedokument für die Fortsetzung in einer Claude-Code-Session. > Übergabedokument für die Fortsetzung in einer Claude-Code-Session.
> Stand: 2026-08-29 — App läuft produktiv auf Gisela unter > Stand: 2026-08-30 — App läuft produktiv auf Gisela unter
> http://172.30.1.11:3300 (nur internes Netz), Downloads nach > http://172.30.1.11:3300 (nur internes Netz), Downloads nach
> `/home/stwaidele/YouTube/<Titel>/`. Neu: Whisper-Transkriptions-Fallback > `/home/stwaidele/YouTube/<Titel>/`. Zuletzt: Fortschrittsanzeige
> für Videos ohne Untertitel, live verifiziert (archive.org en + Instagram > gefixt (eine sich aktualisierende Zeile statt Zeilen-Kaskade),
> de, RTX 3080). > serverseitig live verifiziert.
> Dauerhafte Fakten stehen in `README.md`/`INSTALL.md`; hier steht nur, was > Dauerhafte Fakten stehen in `README.md`/`INSTALL.md`; hier steht nur, was
> **nicht** aus Code und Git-Historie ersichtlich ist. > **nicht** aus Code und Git-Historie ersichtlich ist.
**🔜 NÄCHSTE SESSION:** Kein konkreter inhaltlicher Auftrag hinterlegt. **🔜 NÄCHSTE SESSION:** Kein konkreter inhaltlicher Auftrag hinterlegt.
Beim nächsten echten Download beiläufig prüfen, ob die Fortschrittszeile
im Browser wirklich in-place aktualisiert (Client-Teil des Fixes vom
30.08. ist implementiert, aber noch nicht im Browser beobachtet).
Arbeitskopie auf Gisela: `/home/stwaidele/Claude/yt-dlf` (am 29.08. von Arbeitskopie auf Gisela: `/home/stwaidele/Claude/yt-dlf` (am 29.08. von
`yt-dlp` umbenannt; systemd-Unit-Pfade angepasst, venv läuft weiter — `yt-dlp` umbenannt; systemd-Unit-Pfade angepasst, venv läuft weiter —
pip darin nur noch als `.venv/bin/python -m pip` aufrufen, der pip darin nur noch als `.venv/bin/python -m pip` aufrufen, der
@ -48,6 +51,25 @@ pip darin nur noch als `.venv/bin/python -m pip` aufrufen, der
führende Wiederholungszeilen (`src/lib/subtitle.js`, führende Wiederholungszeilen (`src/lib/subtitle.js`,
`scripts/subtitle_to_markdown.py`, beide identisch halten!). `scripts/subtitle_to_markdown.py`, beide identisch halten!).
## Session 2026-08-30 — Fortschrittsanzeige gefixt (Claude Fable 5)
Stefans Befund (mit Screenshots vom iPhone): jede yt-dlp-Progress-Zeile
erzeugte ein neues Log-Element — hunderte fast identische Kästen.
Ursache: yt-dlp überschreibt seine Fortschrittszeile per `\r` in-place,
die App schickte aber jedes Update als eigenes `log`-Event. Fix:
Server taggt Fortschrittszeilen als Event-Typ `progress`
(`/^\[download\]\s+[~\d]/` — bewusst breiter als nur `%`, weil
Downloads unbekannter Größe prozentlose Zeilen wie
`[download] 440.00B at Unknown B/s` ausgeben; ffmpeg-Zeilen
`frame=`/`size=` ebenso), Client ersetzt bei `progress` die vorige
Zeile, wenn diese auch `progress` war. Serverseitig live verifiziert
(SSE-Stream per curl, „Me at the zoo"); Client-Ersetzung implementiert,
im Browser noch nicht beobachtet. Nebeneffekt des Tests: die am 29.08.
versehentlich mit Whisper überschriebene
`~/YouTube/Me at the zoo/Me at the zoo.en.vtt` ist wieder die echte
YouTube-Caption. Stefans Debug-Screenshots (`IMG_70*.PNG` im
Projekt-Root) bleiben bewusst untracked.
## Session 2026-08-29 — Verzeichnis-Umbenennung & Memory-Umzug (Claude Fable 5) ## Session 2026-08-29 — Verzeichnis-Umbenennung & Memory-Umzug (Claude Fable 5)
Lokales Verzeichnis auf Gisela von `yt-dlp` nach `yt-dlf` umbenannt Lokales Verzeichnis auf Gisela von `yt-dlp` nach `yt-dlf` umbenannt

View File

@ -24,7 +24,15 @@
es.onmessage = (event) => { es.onmessage = (event) => {
const data = JSON.parse(event.data); const data = JSON.parse(event.data);
if (data.type !== 'zip-ready') log = [...log, data]; if (data.type !== 'zip-ready') {
// Progress updates replace the previous progress line instead of
// piling up as new entries (yt-dlp rewrites that line in place)
if (data.type === 'progress' && log.at(-1)?.type === 'progress') {
log = [...log.slice(0, -1), data];
} else {
log = [...log, data];
}
}
setTimeout(scrollToBottom, 0); setTimeout(scrollToBottom, 0);
if (data.type === 'zip-ready') { if (data.type === 'zip-ready') {

View File

@ -88,7 +88,9 @@ async function runDownload(videoUrl, audioOnly, send, signal) {
'--no-playlist', '--no-playlist',
videoUrl videoUrl
], line => { ], line => {
send('log', line); // yt-dlp rewrites its progress line in place (carriage return); tag those
// updates so the client can replace the previous one instead of appending
send(/^\[download\]\s+[~\d]/.test(line) ? 'progress' : 'log', line);
const sub = line.match(/\[info\] Writing video subtitles to: (.+)/); const sub = line.match(/\[info\] Writing video subtitles to: (.+)/);
if (sub) subtitlePaths.push(sub[1].trim()); if (sub) subtitlePaths.push(sub[1].trim());
const merge = line.match(/\[Merger\] Merging formats into "(.+)"/); const merge = line.match(/\[Merger\] Merging formats into "(.+)"/);
@ -152,7 +154,7 @@ async function runDownload(videoUrl, audioOnly, send, signal) {
send('info', `Extracting audio: ${basename(audioPath)}`); send('info', `Extracting audio: ${basename(audioPath)}`);
await runProcess(FFMPEG, [ await runProcess(FFMPEG, [
'-i', videoPath, '-vn', '-acodec', 'libmp3lame', '-q:a', '2', '-y', audioPath '-i', videoPath, '-vn', '-acodec', 'libmp3lame', '-q:a', '2', '-y', audioPath
], line => send('log', line), signal); ], line => send(/^(?:frame|size)=/.test(line) ? 'progress' : 'log', line), signal);
send('info', `Audio saved: ${basename(audioPath)}`); send('info', `Audio saved: ${basename(audioPath)}`);
} }
@ -182,7 +184,7 @@ function runProcess(cmd, args, onLine, signal, spawnOptions = {}) {
const settle = (fn, val) => { if (!settled) { settled = true; fn(val); } }; const settle = (fn, val) => { if (!settled) { settled = true; fn(val); } };
const handleData = data => const handleData = data =>
data.toString().split('\n').filter(Boolean).forEach(onLine); data.toString().split(/\r\n|\n|\r/).filter(Boolean).forEach(onLine);
proc.stdout.on('data', handleData); proc.stdout.on('data', handleData);
proc.stderr.on('data', handleData); proc.stderr.on('data', handleData);