Changeset 834bcc3 in Klonkt for scripts/backfill-durations.mjs
- Timestamp:
- 06/23/2026 06:14:27 PM (3 months ago)
- Branches:
- main
- Children:
- d774679
- Parents:
- bb42dfb
- File:
-
- 1 edited
-
scripts/backfill-durations.mjs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scripts/backfill-durations.mjs
rbb42dfb r834bcc3 1 1 #!/usr/bin/env node 2 2 /** 3 * Backfill audio_tracks.duration voor bestaande tracks die nog géén duur hebben.4 * Leest de duur uit het mp3-bestand via ffmpeg (probeDuration — geen aparte5 * ffprobe -binary nodig). Idempotent: pakt alleen rijen met duration NULL of0,6 * dus veilig herhaalbaar.3 * Backfill audio_tracks.duration for existing tracks that have no duration yet. 4 * Reads the duration from the mp3 file via ffmpeg (probeDuration — no separate 5 * ffprobe binary required). Idempotent: only touches rows with duration NULL or 0, 6 * so it is safe to run repeatedly. 7 7 * 8 8 * npm run backfill:durations 9 9 * 10 * Respect eert AUDIO_PATH (env) net als de upload-route.10 * Respects AUDIO_PATH (env) just like the upload route. 11 11 */ 12 12 import path from 'path'; … … 21 21 ); 22 22 23 // storage_path is absolu ut (opgeslagen bij upload); val terug opAUDIO_DIR/filename.23 // storage_path is absolute (stored at upload time); fall back to AUDIO_DIR/filename. 24 24 function resolveFile(t) { 25 25 const candidates = [t.storage_path, t.filename ? path.join(AUDIO_DIR, t.filename) : null].filter(Boolean); 26 26 for (const c of candidates) { 27 try { if (fs.statSync(c).isFile()) return c; } catch { /* volgende kandidaat*/ }27 try { if (fs.statSync(c).isFile()) return c; } catch { /* try next candidate */ } 28 28 } 29 29 return null;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)