gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfa86b08cfa86b08c|||PR Records 2026-11-24: LOG, STATUS, missions 020-023mrefa86b08c/reports/JB1-jukebox-scanner.md

5.1 KB

  1. # JB1 report: jukebox library scanner, mpackdb database and JSON API
  2. **Status: done, committed on main in /media/STORAGE/projects/WorldAPI/jukebox. Not deployed, nothing listens, no screens yet.**
  3. ## What exists
  4. - An ID3 reader written in Hybriel (v2.2, v2.3, v2.4, unsynchronisation, extended header, POPM of every owner, PCNT, APIC, ID3v1 fallback), the mp3 duration from the first frame or the Xing/VBRI header, and ffprobe for every other format.
  5. - A scanner that compares path, size and change time, removes vanished files (only below a library path that could be listed) and runs as a child process under nice and ionice, so the server keeps answering while it scans. It runs 2 seconds after start, every 30 minutes after the last scan, and on `POST /api/rescan`.
  6. - Covers: embedded picture or folder.jpg/cover/front/AlbumArt, stored once by content hash in storage/covers.
  7. - mpackdb tables songs, albums, artists, covers, scans; a search field and sort keys; the JSON API (stats, songs paged and sorted, artists, albums, search, shuffle, cover, rescan, settings). README has the schema and the API.
  8. - Gate `node tests/gate.mjs`: 119 checks, 0 failed (fixtures built by `tests/make-fixtures.mjs` with ffmpeg and hand-built ID3 frames: v2.2, v2.3, v2.4, extended header, unsync, two POPM owners, PCNT, APIC, folder cover, ID3v1 only, no tags, commas, an ogg). I proved the gate fails on broken code twice: with the unsynchronisation step removed 8 checks fail, with the comma protection removed 6 fail.
  9. ## The full read-only scan of the real library (/media/SLOW1TB1/Musik, nice -n 19 ionice -c3)
  10. | | JB1 | JB0 |
  11. |---|---|---|
  12. | first scan | 706 s (an earlier identical run: 520 s; the machine is busy) | about 3 min for mp3 tags only, no ffprobe, no duration |
  13. | rescan without changes | 0.4 s (5.3 s once, with a cold disk cache) | |
  14. | files seen | 13,450 (13,449 stored, 1 unreadable by ffprobe) | 13,115 mp3 + 312 ogg + 9 aac + 9 wav + 2 m4a + 2 ape + 1 wma = 13,450 |
  15. | songs / artists / albums | 13,449 / 3,966 / 9,985 | 730 album folders |
  16. | play count at least 1 | 8,327 | 8,324 |
  17. | play count at least 5 | 4,572 | 4,572 |
  18. | covers | 295 distinct pictures, 5,612 songs with a cover | 4,424 mp3 with a picture, folder covers in 118 of 730 folders |
  19. Storage: 30 MB database, 38 MB covers. After the scans `find /media/SLOW1TB1/Musik -cnewer <marker>` printed nothing: the library was not touched.
  20. Differences explained: the 3 extra songs with a play count come from files with several POPM frames whose last frame holds 0; JB0's script kept only the last frame, we take the highest of all. The albums are many (9,985, 9,622 of them with one song) because an album is album artist + album name + folder and `hurchi` holds thousands of loose songs with their own album tags. Songs with a cover are more than the 4,424 pictures because folder covers are added.
  21. The default "5k to listen to" filter: `minPlays=5` gives exactly 4,572 songs (`/api/songs?minPlays=5`, `/api/shuffle?minPlays=5`).
  22. API speed on the real database (warm): a song page 3–5 ms (first call of an order builds the 13k id list: 0.16–0.25 s), search 0.3 s, artists/albums pages 10–30 ms, shuffle 40 ms.
  23. ## Gaps and findings (for Atlas to route)
  24. 1. **mpackdb bug: an indexed value containing a comma is lost when the table is opened again** (the index file is `key,offset,length` lines). It silently dropped 271 songs from the sorted lists after a restart. Repro: `.scratch/mpackdb-comma-key/repro.hl` ("range before close 2, after reopen 1"). Worked around with comma-free index keys (`safeKey` in lib/util.hl) and by not indexing path and folder; the gate has a comma fixture.
  25. 2. **mpackdb 1.0.10 was not found** (no tag, no newer plugin copy anywhere). I used the newest plugin on loreana (gitoria's, hybriel c1b1010f); all use is behind `lib/db.hl`, so switching is a copy of `plugins/mpackdb`. Day26 upsert/remove: none used (grep).
  26. 3. **hl:fs has no ranged read and no stat** (hybriel#233, mission 483 is only a brief). Workaround: `head -c`/`tail -c` through hl:proc, one process per file; sizes come from `listDir`, the change time from `changeTime`. When #233 lands, `readHead` in lib/tags.hl is the one place to switch.
  27. 4. A scan run inside the server (timer handler) blocked every HTTP request until it ended; so the scan is a child process. Worth a Hybriel look: a `run()` or a long handler holding the event loop.
  28. 5. Minor Hybriel facts met: `from` reserved; no semicolons; a `.hl` file is one class; `Bytes.text()` on invalid UTF-8 cannot be caught; `String.fromCharCode` takes exactly one argument; `JSON.parse` cannot be caught (jsoncheck.hl copied from notes).
  29. ## Not done / next
  30. No player screen, no audio streaming route with Range requests, no playlists, no login. Folder covers added later show only after a song of that folder changes. Pictures inside ogg/m4a/flac are not extracted. One file is unreadable by ffprobe on every scan (not identified). The next mission: UI (hybriel and layout components), `/api/stream/<id>` with Range (needs #233 or a process read), playlists table, now-playing overlay.
  31. Files: README.md (schema, API), STATUS.md, LOG.md, DECISIONS.md, tests/, tools/scan.hl. Scratch left: /media/STORAGE/claude-scratch/atlas/JB1/real (the real-library database, 70 MB), nothing running.

Branches

Latest commits

  • fa86b08c|||PR Records 2026-11-24: LOG, STATUS, missions 020-023mre
  • 0a2ae3daMerge remote-tracking branch 'origin/records-1123' into records-1124mre
  • 9a48cfcaMerge branch 'vendor-theme' into mainJukebox
  • 170d3735Merge branch 'code-order-2' into mainJukebox
  • 3f1918a7|||PR Re-sync layouts theme 4099e64 with Segoe UI firstmre
  • 2e7f6a43Vendor virtual-list 489afcf from components.hybrielmre
  • 0ba85799Merge branch 'reset-classes' into mainJukebox
  • 502eeed5jukebox#20: vendor virtual-list initial resetKey baseline fixmre
  • 6d5ce287|||PR jukebox#9 Centralize songs table reads and writes in db.hlmre
  • dcca21abjukebox#8 Move copies and queue logic into their topicsmre
  • 3b76651cjukebox#20: update virtual-list README pin and resetKey optionsmre
  • bc09e1e8|||PR jukebox#20: reset virtual lists through resetKey (partial validation)mre
  • a3796dc5Records: live step waits for idlemre
  • 3b158e16Records: merges of #9 and #11mre
  • 27204167Merge main into records-1123mre
  • 10f8a8c8Merge branch 'code-order' into mainJukebox
  • 204fc828Merge branch 'day72' into mainJukebox
  • 8e8d0e2b|||PR Records: PROCEDURES.md, missions 016-019, GO 2026-11-23mre
  • 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
  • 33072bb5|||PR Record day72 gates and Chrome proofmre