Skip to content

Watch: movies, television, and anime

Outcome and requirements

Kostas wants one private place to remember what he watched, write reviews, choose what to watch next, and see upcoming releases. Watch is available in the shared web application, including the Android shell, and to the signed-in user's agents.

The delivery includes:

  1. A private library of movies, TV series, and anime. Add a title manually or search a metadata provider and import the selected result. Keep provider IDs and links so similarly named titles are distinguishable.
  2. A watchlist ordered by priority, plus watching, completed, paused, and dropped states. Filter by title, category, status, and personal label.
  3. Dated viewing history, optional season/episode numbers, episode progress, a personal rating from 0 to 10 in half-point steps, and a Markdown review. A rating and review are independent of completion. Rewatches add history.
  4. On-demand title, synopsis, poster, genres, year, runtime, episode count, and release information. Imported genres stay separate from personal labels. Refresh metadata without changing private progress or writing.
  5. A date-range release agenda for saved titles and a separate discovery view for upcoming movies and series premieres. Label source and date precision; a premiere or broadcast date does not promise local streaming availability.
  6. Agent tools to search metadata, list and read the library and history, save titles, update progress/reviews, refresh metadata, and read the calendar. Agents combine these with existing web search/read tools to recommend titles, explain choices, link sources, and save only when asked.

Public social reviews, playback, streaming subscriptions, account synchronization with other trackers, automatic scheduled scouting, and notifications are outside this delivery. No existing watch data needs migration.

Research and provider decision

Reviewed 2026-11-12 against provider documentation:

Source Coverage and access Decision
Cinemeta Public Stremio movie search/details; IMDb string IDs and supplied poster URLs Default movie lookup without secrets. Search uses metas; details uses meta. Link the IMDb title page.
Jikan Public MAL anime metadata, including series, films, OVAs and specials; numeric MAL IDs Default anime lookup without secrets. Cache one hour, pace uncached calls to less than 60/minute per process, honor bounded 429 cooldowns and link the MAL source page.
TMDB Movie/TV metadata and artwork; API token required; noncommercial use requires attribution Optional movie/TV lookup; existing TMDB entries retain import and refresh support. Configure TMDB_READ_TOKEN server-side. Include the approved logo and notice in Watch credits.
TMDB discovery Date-filtered movie discovery; TV details includes episode information Use movie release and TV premiere discovery; saved series retain their next known episode.
TVmaze Public TV/anime metadata and episode schedules without a token; CC BY-SA attribution; rate limits and caching Default series search. Save only selected titles; cache lookups for an hour, link source pages, and return a retryable error on outages.
AniList Anime metadata and schedules, but prohibits independent competing list/tracker services Do not integrate.

Jikan handles anime films as media_type=movie and series/OVAs/specials as media_type=tv, independently of the anime user category. An omitted format searches all anime formats. Cinemeta handles movies, TVmaze retains TV episode guides, and TMDB remains optional. Manual entries remain available when a title cannot be found. Unknown dates stay unknown. Discovery requires TMDB configuration and is paginated; it is not presented as a complete worldwide release schedule.

Design

loryth-watch is a FastAPI service with its own PostgreSQL database and service credentials. The API uses the shared IAM middleware, response envelopes, DI, and transaction manager. Every record query includes the signed-in user ID; callers cannot select another user through a request field. The gateway exposes /api/v1/watch. Health checks also cover Watch during deployment.

A library entry is a versioned aggregate: provider metadata snapshot, private status, priority, personal labels, rating, review Markdown, progress, and viewing history. The repository stores the typed aggregate as JSONB with indexed user and provider identity columns. Unique (user_id, source_key) prevents duplicate imports. Manual entries have no provider identity. Title edits require the current revision and lock the aggregate, returning 409 on a stale edit. A metadata refresh only replaces its snapshot; it cannot change ratings, labels, review, or history.

Provider requests use fixed HTTPS origins, bounded responses, timeouts, and a bounded one-hour cache. No caller-supplied URL is fetched by Watch. Credentials remain server-side. Outages leave saved records readable and editable. Provider failure messages never include credentials or raw upstream responses.

The saved-title agenda reads cached snapshots without network calls. Refresh a title explicitly to update postponed releases. Dates are inclusive and date-only events are displayed without an invented timezone or midnight time. TVmaze supplies dated episodes. TMDB import and refresh fetch each season's dated episodes in batches of at most 20 seasons, alongside the premiere and next known episode. Search results do not fetch seasons. Discovery is separate from the private agenda and never auto-adds items.

The UI reuses app navigation, tokens, forms, Markdown rendering, and query-cache patterns. Shared TypeScript API contracts live in ui/packages/api. The Android shell loads the same web application and needs no shell code or version change.

The library home at /watch shows horizontal rows for Continue watching, the priority-ordered watchlist, Movies, TV shows, and Anime. Empty rows stay hidden. Series in Continue watching show the next episode and a Mark watched action; progress appears when the provider supplies an episode total. Movies link to their details. Poster cards show status and rating, with priority replacing the year in the watchlist row.

The home search and each See all link open /watch/search. Its q, kind, status, and label URL parameters preserve the current filters. Type and status chips update that URL; Load more appends another 25 results. Press / outside a text field to focus search. Find a title and Release calendar remain separate tabs.

Agent tools pass the current bearer token to Watch. Reviews and history are paginated in agent reads so long reviews remain fully accessible within tool response limits. Review replacements require the revision returned by a full read, with instructions to preserve existing text.

Source attachment and cover repair

Source contracts are discriminated by provider: Cinemeta uses an IMDb string such as tt19500164, while TVmaze, Jikan and TMDB use positive numeric IDs. Cinemeta accepts movie sources only; TVmaze accepts TV sources only. No stored source IDs need migration. UI contracts are handwritten in watch.ts; no generated OpenAPI files are edited.

GET /providers returns a map of {configured: boolean, health: "unknown"}; configuration is separate from upstream health, and this read makes no provider calls. Search defaults to Cinemeta for movies, TVmaze for TV and Jikan for anime. Provider outages return 503 without changing records.

GET /entries?missing_cover=true filters the stored cover URL before counting and pagination. False selects covered entries, omission returns all entries. MCP list_watch includes cover_url, source, year, revision, page_size and next_page along with personal fields. Its page size is at most 25; an oversized tool result fails with instructions to reduce page size instead of silently omitting titles. Enumerate all pages before repair writes, since each successful cover attachment changes the filtered result set.

POST /entries/{id}/source accepts {expected_revision, source}. MCP exposes this as link_watch_source. The service checks the revision before fetching, fetches provider metadata, then locks and rechecks the entry before saving its payload and indexed source key together. It fills only missing metadata, preserves the user title/category and all personal fields, and updates the source URL to the selected provider. Existing nonempty metadata is retained. An identical repeat with the current revision is a no-op; a stale revision is always a conflict. Source uniqueness includes dropped entries. A collision returns 409 and rolls back; it never merges or creates an entry. Import/save creates a title and reuses only an exact provider-linked entry. Refresh requires an existing source and replaces its provider snapshot.

Errors use detail: {code, message} with provider_not_configured, provider_unavailable, source_required, revision_conflict, source_conflict or entry_not_found. MCP translates only recognized code/status pairs to fixed, safe messages, never arbitrary backend messages. Read-only failures never imply that writes may have occurred.

Repair only clear matches after checking year, remakes, seasons, specials and film format. Continue clear matches while asking one grouped question about ambiguous candidates. Verify the saved cover and personal fields and summarize counts and unresolved titles. Never import to enrich manual entries or change status/labels to conceal duplicates.

Episode tracking

TV and anime pages show Episodes above the review form: next up, collapsible seasons, watched progress, and individual 0–10 half-point ratings. Mark episodes or aired seasons immediately; rating an episode also marks it watched. Future episodes are disabled. Earlier gaps and existing manual progress can be marked in one action. Marks missing from refreshed metadata remain editable. Episode ratings have their own average; they never replace the overall title rating.

PATCH /entries/{id}/episodes accepts 1–2000 unique (season, episode) changes. Each change includes watched, with optional watched_on and rating. A new mark defaults to today's UTC date; an existing mark keeps its date and rating unless supplied. Null clears a rating. Unwatching removes the mark and rating; supplying a rating while unwatching returns 422. Future watched dates return 422. The endpoint locks the entry and increments its revision without requiring an expected revision, so successive episode updates can save independently.

Entries store episodes with an empty default for older documents. Once marks exist, personal progress edits derive episodes_watched from their count. Metadata attachment and refresh preserve the stored count, including legacy partial marks. Removing the last mark resets the counter to zero; entries with no marks retain manual progress. A viewing with both season and episode adds a missing mark while preserving existing marks.

Entry responses and library summaries include next_episode without storing it in JSONB. It is the first aired episode after the latest watched episode in air order (date, season, episode); specials are excluded. Earlier gaps do not move next up backwards. Status changes remain explicit, including Mark completed. Watching cards display next up. Review drafts keep their current revision after episode changes that leave the title's personal fields unchanged.

Chat's mark_watch_episodes accepts up to 500 changes. Agents expand ranges into individual episodes before calling it. read_watch omits the guide and marks, returning next up, progress, and the most recent 50 rated episodes with their total count instead.

Delivery stories and acceptance

  1. Save and browse a private library. A user can add all three categories, import a chosen provider result once, and filter their entries. Another user cannot read, edit, refresh, or delete them. Depends on service/database wiring.
  2. Choose and record watching. A user can order the watchlist, change states, record a dated movie or episode viewing, and edit progress. Repeated viewings remain visible. Invalid dates, ratings, and negative progress are rejected.
  3. Review a title. Rating and Markdown review persist together or separately; formatted preview uses the app renderer. Concurrent edits return a conflict without overwriting saved text. Depends on the library aggregate.
  4. Enrich selected titles. Search returns distinct provider IDs, titles, years, covers, and links. Import/refresh stores genres and release data without changing private fields. Provider outages and missing tokens have useful errors.
  5. Plan upcoming viewing. Calendar shows known saved-title releases in an inclusive date range, source links, episode numbers, and unknown-date guidance. Discovery shows paginated upcoming movie releases and series premieres when TMDB is configured. Depends on metadata import.
  6. Ask an agent. The agent can read preferences, reviews, progress and queue, search metadata and public web sources, suggest titles with reasons, and save a requested choice. Writes respect current-user access and revision checks.
  7. Run on Snoopy. Frozen dependency install, focused server tests, affected UI checks, Compose validation, Sylox checks, merge, publish, and deploy complete; Watch health is checked through the public gateway.

Test on Snoopy

Open Watch, search TVmaze for a series, import it, and add a personal label. Set its priority and move it through Watching to Completed. Record an episode and a rewatch; verify history survives refresh. Save a half-point rating and a review containing headings, emphasis, and a link. Check the release agenda. Import a Cinemeta movie and Jikan anime without credentials. With TMDB_READ_TOKEN configured, browse optional upcoming discovery. In Chat ask for suggestions based on the library, then ask to save one.

Deployment configuration

Set DB_PASSWORD_WATCH=<SECRET_VALUE> in the installation's private Compose environment. The migration container uses POSTGRES_USER and POSTGRES_PASSWORD to create the separate Watch role/database on an existing volume; it does not reset an existing role's password. Fresh volumes create Watch alongside the other service databases. Cinemeta movies, Jikan anime and TVmaze TV need no token. Optionally set TMDB_READ_TOKEN=<SECRET_VALUE> to enable TMDB lookup and upcoming discovery. Use TMDB's API Read Access Token, rather than an API key or a Loryth sign-in token. Restart Watch after changing it.

The UI reports unavailable provider configuration and keeps private library editing, manual additions and the other providers available. Provider requests are on demand; there is no scheduled metadata refresh or recommendation job.

Provider recovery and candidate inspection

Anime searches use Jikan first. If that lookup fails, Watch searches TVmaze for series and Cinemeta for films within the same ten-second lookup budget, even when provider=jikan was selected explicitly. An explicit media_type limits fallback to that format; omitting it allows both. Each search attempt has an overall four-second timeout so address retries cannot consume the fallback budget. Returned sources identify the provider that supplied each candidate. Alternative results never establish a season/OVA/special match automatically. Refresh and source details always use the selected provider ID and never silently substitute another title.

Connection failures pause further requests to that host for sixty seconds. Upstream rate limits honor bounded Retry-After cooldowns, while local queue pressure is reported separately. Provider errors may include the validated retry_after_seconds field alongside code and message. Connection errors use provider_connection_failed, upstream 429 responses use provider_rate_limited, and local pacing refusals use provider_queue_busy. These errors do not establish a global outage. Agents should use alternatives instead of retry bursts or shell sleeps during the current turn.

POST /metadata accepts {kind, source} and reads full provider details without creating or changing a library entry. MCP exposes it as read_watch_source; release lists are omitted from that tool's result. Read an existing entry's review and history, then candidate details, before asking the user about an ambiguous match. Stored source links, director names and plot descriptions can distinguish identically named films. Candidate reads never emit a saved-item card and do not need an entry revision.

Cinemeta may redirect between v3-cinemeta.strem.io and cinemeta-live.strem.io. Watch allows at most two HTTPS redirects within that host pair on the standard port. It rejects other destinations and redirects on authenticated provider requests, retains the operation deadline, and caches the result under the original lookup URL.