Laev.Resume (laev v0.1.40)

Copy Markdown View Source

Per-title "continue watching" memory: the last season/episode + the exact source (torrent) the user played for each movie/show, so they can resume without re-hunting the source list. Held in ETS and mirrored to a JSON file so it survives server restarts. Time-within-the-episode is remembered separately, client-side (localStorage keyed by the remux id), and resumes automatically.

Entries are plain string-keyed maps (JSON round-trips cleanly):

%{"type", "tmdb_id", "season", "episode", "title", "poster_path",
  "source" => %{"name", "magnet", "hash"}, "updated_at"}

Summary

Functions

All resume entries, most recently updated first.

Forget a title's place entirely. The next sync turns the gap into a tombstone, so the removal travels to your other devices rather than being undone by the first pull.

The resume entry for a title, or nil.

Make sure this scope's table exists. Asking for it is enough.

Record (or update) where the user is in a title.

Drop the cache and re-read resume.json — for when something other than put/3 rewrote the file (a sync pull). Without this the stale table would not only show old history but clobber the synced file on the next persist.

Functions

all()

All resume entries, most recently updated first.

delete(type, tmdb_id)

Forget a title's place entirely. The next sync turns the gap into a tombstone, so the removal travels to your other devices rather than being undone by the first pull.

get(type, tmdb_id)

The resume entry for a title, or nil.

init()

Make sure this scope's table exists. Asking for it is enough.

key(type, tmdb_id)

put(type, tmdb_id, entry)

Record (or update) where the user is in a title.

reload()

Drop the cache and re-read resume.json — for when something other than put/3 rewrote the file (a sync pull). Without this the stale table would not only show old history but clobber the synced file on the next persist.