Add save-to-device export, server export route and an On other devices P2P list

This commit is contained in:
Claude
2026-10-01 18:53:00 +00:00
parent 08e95814e5
commit 02b337fcbc
10 changed files with 385 additions and 0 deletions

View File

@@ -38,6 +38,14 @@ JSON shapes mirror the Tauri Rust bridge exactly — don't change one side alone
- Videos over `transcode.maxSeconds` are never re-encoded (lane would be tied up for hours).
- Deferred ideas (Cloudflare Worker fetch, Android device download): `docs/deferred-ideas.md`.
## Save to device + "On other devices"
- `exportToDevice(video)` (app.js, helpers in `frontend/export.js`): puts the file in Photos / Files / Downloads.
Source order: copy saved in OPFS → server copy (`GET /api/export/:id?name=`, attachment + Range; direct
download on desktop, via OPFS + share sheet on phones) → online P2P holder → normal save via server.
Buttons appear only once the file is ready: `navigator.share` needs a fresh tap.
- `GET /api/p2p/available` + view `{type:'p2p'}` = the "📡 On other devices" list (sidebar, web only):
verified files with ≥1 sharing holder, online first, stale flagged. Rows play, export, or go to a playlist.
## Server media cache (`server/media-cache.js`)
- Every played (`/api/streams`, LOW priority, ≤ `MEDIA_AUTO_MAX_SECONDS`, default 3 h) or saved
(`/api/download`, HIGH, ≤ 3 h) video gets ONE copy: `$MEDIA_DIR/<id>.<gen>.mp4`