gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1838d7e81838d7e8Records: S1 startedmre1838d7e8/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

  • 1838d7e8Records: S1 startedmre
  • a43fca3fRecords: mission 001 decided pointsmre
  • 41773828Records: statusmre
  • a82c0805Records: mission 001 brief (Style form)mre
  • a4bce6d1Records: ticket push subscriptionmre
  • 14abde3bjukebox: records: Atlas's records moved to worldapi-conductor/archivemre
  • 0433e9a8jukebox: records: gitoria remote added and pushedmre
  • 1722d707jukebox: records: repo creation handed to Gitoriamre
  • b42e7dfbjukebox: conductor records (CONDUCTOR.md, STATUS.md), old STATUS archivedmre
  • 1b0d0bc1jukebox: a startup error prints its message before exit 1 (hybriel#247)mre
  • b19c478bjukebox JB18 (jukebox#17): onto Hybriel set-day31 (b287cd82, contains the SIGPIPE fix 6d2ca454): plugins/core and plugins/web re-vendored, bin/ from the set; a client that closes /stream while it is written no longer kills the server (90 aborted streams survived, the old bin died with exit 141 on the first)mre
  • 73867a2ejukebox#2: Style blocks in the language's nested form (rules named after the View's own elements, pseudo-classes nested, merged duplicates); the same CSS rules, the pages look the samemre
  • 06c548d6jukebox JB15: report, log linemre
  • 980859cbjukebox JB15 (jukebox#15): the now-playing overlay on a short screen (tablet or phone on its side) gave the queue 12 to 100 px because the big cover took the room; the cover now shrinks with the screen height and goes away under 41rem, the queue keeps 3+ rows; gate tests/jb15.mjs at 8 sizesmre
  • 9efc40ffjukebox#12 #14: Grok session 1793246574527-181160mre
  • 7d58b36ejukebox JB13 (jukebox#13): Next and Previous ask for the songs after / before the current song's id in the current order, not for place + 1; gate tests/jb13.mjs checks Next with the queue down to one song after the order changedmre
  • 51358794jukebox JB14 (jukebox#14): the Songs screen opens sorted the way it was left (kept on the server in storage/ui.json), the sort control shows the sort the rows really have (selected options, autocomplete off); gate tests/jb14.mjsmre
  • cc68a063jukebox JB13 (jukebox#13): a tapped song plays the song that was tapped, found by its id in the list as it is now (not by its row number, which counted plays move); the queue goes on from its place there, the rows refresh on the tap; gate tests/jb13.mjs (songs by plays, favourites)mre
  • 88d3d5c1jukebox JB12b (jukebox#12): the scroll handle is big (2.75rem x 4rem, accent colour, grip) and drawn on every device, no media query; native bar hidden; gate tests/touch.mjs checks the drawn width with and without touchmre
  • b58e4495jukebox JB11 (jukebox#11): the next song starts in the ended event on the same audio element, so it also starts with the screen locked; gate tests/jb11.mjs (hidden tab, no frames)mre