feat(media): a local library of uploads — media ls with names, media link; canonical grant encoding

The relay never knows names and a link is printed once, so a lost link
made an owned film unreachable. media put now appends each upload and its
grant to $XDG_CONFIG_HOME/shade/media-library.jsonl (0600, one JSON line
per change: concurrent uploads cannot lose entries, a torn line costs only
itself). media ls names uploads from it; media link <name|id> prints the
link again; media rm forgets it.

encodeGrant now writes meta in canonical (validateMeta) order, so one
grant is always one link; media.json vectors regenerated (album and
subtitle vectors only), Kotlin 82/0.

Verified: 82 TS tests (library: fold, find, 0600, torn line, 200
concurrent appends, stable encoding); CLI put → ls → link gives back the
identical link.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-18 22:08:22 +02:00
parent d784e47ab3
commit 01f8471fb5
8 changed files with 269 additions and 25 deletions

View File

@@ -56,6 +56,10 @@ New package **`@shade/media`** — see `docs/media.md`.
is copied, the rest becomes H.264/AAC, embedded text subtitles become
subtitle tracks, all in one ffmpeg pass. Without the flag, `put` warns
when ffprobe sees streams browsers will not play.
- **Library.** `media put` records each upload and its grant in
`$XDG_CONFIG_HOME/shade/media-library.jsonl` (0600, append-only); `media
ls` shows names, `media link <name|id>` prints a link again. Grants now
encode their meta canonically, so one grant is always one link.
- **Kotlin.** `no.zyon.shade.media`: SMF1 reader and sealer, grants, live
subscriber and publisher — byte-for-byte against `test-vectors/media.json`.
`:shade-android-media` plays sealed files in Media3/ExoPlayer