gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain10f8a8c8Merge branch 'code-order' into mainJukeboxmain/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

  • 10f8a8c8Merge branch 'code-order' into mainJukebox
  • 204fc828Merge branch 'day72' into mainJukebox
  • 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
  • 33072bb5|||PR Record day72 gates and Chrome proofmre
  • 95f2cd73|||PR Use typed parent methods for screen playback and local server facesmre
  • 6422a020Sync media-player at 51c3818mre
  • b582ba1cVendor complete Hybriel day72 plugin setmre
  • 02dccbc9Merge branch 'records-1119' into mainJukebox
  • a39e1c23|||PR Records: missions 013-015, reconnect fix livemre
  • fc7db075Merge branch 'reconnect-retry' into mainJukebox
  • ac6f4c6fL2: plain declaration for a in pickedNextmre
  • 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
  • 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
  • 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
  • 1f0cd77bMerge branch 'records-day41' into mainJukebox
  • 67be229f|||PR Records: day41 live (PR #4), mission 012, statusmre
  • 0bb027daconductor: caramboleyo is the user, not owner/creatorApollo
  • 04f5d9d5Merge branch 'day41' into mainJukebox
  • 8ed6da45|||PR README: media-player pin df9e7dfmre
  • d5d45fc3|||PR media-player df9e7df (repeat-one fix), sync pin and SOURCEmre