redseat-api
Rust client for Redseat media servers. Work in progress.
let cloud = http?;
let session = cloud.sign_in_with_google_id_token.await?;
let servers = cloud.list_servers.await?;
let client = connect_http.await?;
let server = new;
let libraries = server.get_libraries.await?;
let page = server.library
.get_medias_page
.await?;
A media's file: library.get_media(&media, &MediaFileQuery::default()) downloads it whole (decrypted in an encrypted library), and library.media_url(&media.id, ...) gives its URL with a server token, for a video player that streams it with range requests. In an encrypted library, library.open_encrypted_media(&media) reads its plaintext by ranges (read_at), decrypting only what is read.
Lists for a sync: get_tags, get_people, get_series, get_movies, get_episodes and get_books take the server's queries; with after, only what was modified strictly after it comes back, paged with limit and offset. get_deleted lists deletions the same way.
Mirror (feature mirror)
A local SQLite copy of a server's libraries, kept in sync in the background and read at once, offline too, like the Redseat phone app does. Native targets only.
use ;
let mut options = new;
options.thumbs_limit = 2 * 1024 * 1024 * 1024; // thumbnail cache: 2 GB
let mirror = open.await?; // reads work now, offline too
mirror.connect; // ServerApi: sync every library, live events
mirror.set_priority; // the library on screen syncs first
let mut events = mirror.subscribe; // Changed { library, kinds }, Sync { .. }, ...
let count = mirror.count_medias.await?;
let medias = mirror.medias_at.await?;
let thumb = mirror.thumb.await?; // disk cache, fetched once
mirror.disconnect; // sign-out: stop syncing, keep the data
- Everything per library: medias, tags, people, series, movies, episodes and books, with their relations, and the library list. One file per server, at the path the app gives; thumbnails go in a
thumbsfolder next to it. - The first sync is full; later ones fetch what changed since the last one (with a 1 ms overlap) and apply the deletions. Live events are applied as they come, and a reconnection catches up. A lost sync state means one full repair.
- Encrypted libraries are stored as the server sends them;
set_passphrasethen decrypts thumbnails on read. They stay encrypted on disk. - The storage is behind the
MirrorStoretrait (SqliteStorehere).
Desktop apps can get the Google ID token with google::GoogleSignIn (browser sign-in with a loopback redirect and PKCE). See examples/sign_in.rs.
- Data types are the server's own, from
rs-plugin-common-interfaces(redseat_api::types). - Encrypted libraries use the server's own implementation, from
redseat-crypto(redseat_api::crypto). - Builds for
wasm32-unknown-unknown. UniFFI and wasm-bindgen bindings are planned.
Licensed under MIT or Apache-2.0, at your option.