pub fn pick_current_episode(
series_id: &str,
episodes: &[MediaItem],
next_up: &[MediaItem],
resume: &[MediaItem],
) -> Option<MediaItem>Expand description
The episode a viewer should land on when they open series_id.
Order of preference, and why:
- An episode in progress. That is literally where playback stopped; Next Up would skip past it. On a tie the earliest in series order wins, so a viewer who dipped into a later episode still returns to the one they are working through.
- The server’s Next Up for this series — it accounts for watch history we do not cache locally.
- The episode after the furthest-watched one, falling back to the first
unwatched episode when nothing has been watched or the series is finished.
This is the offline path:
OfflineRepository::get_next_up_episodesreturns an empty vec, so without this rung the whole feature would be online-only. It deliberately does not return the first unwatched episode outright — an unwatched episode behind the viewer’s furthest point was skipped on purpose, and sending them back to it is the bug DR-101 was reopened for. - The first episode, so a never-watched series opens on its premiere rather than on nothing.
next_up / resume entries are honoured even when absent from episodes
(the season fan-out can miss an id the server returns), but only when they
belong to this series.