# 010 — Current state (audit 2026-10-01)

## 1. Watch data that exists

| Store | Written when | Content | Problem |
|-------|--------------|---------|---------|
| `global_watch_history.json` (`user_data.add_recently_played_item`) | at **start** of an addon play (`utils.play_movie_from_addon`, `_on_episode_playback_start`, `SeriesSearch`, AI dialog) | last 50 titles, one entry per title, episode = last started S/E | no position, no end, no watched state |
| `mytv_history/`, `mycinema_history/` (`ChannelHistory`, `ProgressManager`) | MyTV / MyCinema playback | per-channel series progress, resume points, watched films | channel-scoped; stays as is (decision 3) |
| Kodi `MyVideos131.db` | Kodi itself, for library items and for plugin items keyed by `original_listitem_url` | playcount, bookmarks | Kodi never announces changes for non-library files (`VideoDatabase::SetPlayCount`, 21.3) |
| `watchlist_movies.json` (3), `watchlist_series.json` (12) | "Moje filmy / Moje seriály" in the addon | TMDb entries | kept as the lists (030 §5) |

## 2. Playback paths

- Movie from the addon: `RunPlugin(play_movie_from_addon)` → source dialog /
  autoplay pick → `PlayMedia(plugin://…?action=play&ident=…&name=…&tmdb_*)` →
  `action=play` → `setResolvedUrl`. The URL changes with every file, so Kodi's
  own state for it is per file, not per title. `tmdb_id` is not in the URL.
- Episode from the addon: same pattern (`search_and_play_episode`,
  `play_episode_from_addon`).
- MyTV / MyCinema: Kodi video playlist of lazy URLs
  (`play_episode_from_addon_playlist`, `play_movie_from_addon_playlist`),
  countdown via `PlaylistCountdownMonitor`.
- Kodi library `.strm`: `play_*_from_library` → `PlayerMonitor` with
  `temp_autoplay_active` → countdown → next episode **from the Kodi library**;
  fallback "episode + 1 in the same season" breaks at season ends.

## 3. Structural limits

- `AutoplayPlayerMonitor` is created inside a **plugin invocation**; that
  process ends after the action, so tracking there is unreliable. Long-lived
  tracking must live in the service.
- `wcs/metadata/TMDbCache.py` kept every response in one JSON file rewritten
  on every write; service and plugin processes write concurrently → lost
  updates. (Resolved 2026-10-01: it is now a facade over `meta`, 030 §3;
  `tmdb_cache.json` is gone.) The old season / episode listings also called
  TMDb live on every open with no cache (now served from `meta`).
- Kodi shows its own "Mark as watched", "Resume" and "Remove resume point"
  context items for playable plugin items (`video/ContextMenus.cpp`); without
  syncing they would show a different state than the addon.
- skin.milionar reads the Kodi library in: Continue (`widget_in_progress`
  library part, `lib_resume`), search rows "V mé knihovně", game topic picker
  1122 and row "Hrát o…" (`_random_library_entries`), info dialog button
  (DBID-based `lib_*` actions).

## 4. Useful pieces to reuse

- Kodi playlist + lazy resolving URL pattern from MyTV (autoplay without a gap).
- Countdown dialogs (`wcs/playback/dialogs/countdown.py`, four styles) and the
  info dialog with the game.
- Widget fast path, cache files, refresh token, `skin_run` URLs
  (`docs/plan/skin-milionar/060`).
- Autoplay file pick and its harness (`search-harness` skill).
- `Files.SetFileDetails` JSON-RPC (21.3 schema: file, media=video, playcount,
  lastplayed, resume{position,total}) for mirroring state into Kodi.
