Move a single season of a TV show (#4)
CI / test (push) Successful in 1m14s

Shows can be expanded to list their seasons, each with its size and its own Dry run / Move buttons. A season joins the same show on the other
server, so finished seasons can go to the big server while the current one stays on the fast one.

- Source exports a season from the show folder, with a manifest of just that season's folder plus the show's loose non-video files. Refuses
  seasons with no folder of their own, or whose folder holds otherseasons' episodes.
- Destination finds the show by provider ID, then name. If it already has the show, the show's own files are skipped (Job.skip_files) and
  never overwritten; otherwise they come with the season. Refuses if the season folder already exists.
- Only episode watch state is carried for a season.
- Source trashes just the season folder; after the last season, the leftover show folder joins it in the same trash entry if no videos
  remain. The chosen trash entry is saved so a re-run after a crash finishes in the same place.
- New GET /seasons (UI and peer). Fake Jellyfin gains season items.
- e2e tests: season into a new show, into an existing show, last season leaving, destination already has the season, misfiled episodes.
This commit is contained in:
IxianPixel committed 2026-11-06 17:02:40 +00:00
1 parent 25a743b350
commit 484ac50508
21 files changed
+959 -111

No files matched your search

+43 -2
View File
@@ -38,6 +38,16 @@ impl std::str::FromStr for JobId {
pub enum ItemKind {
Movie,
Series,
/// One season of a series, moved on its own into the show's folder.
Season,
}
impl ItemKind {
/// Whether the item has episodes whose watch state is mapped by
/// (season, episode).
pub fn has_episodes(self) -> bool {
matches!(self, ItemKind::Series | ItemKind::Season)
}
}
/// The last milestone a job has *completed*. The runner looks at the stage,
@@ -129,10 +139,31 @@ pub struct ExportInfo {
pub rel_folder: String,
pub manifest: Manifest,
pub user_data: Vec<UserDataRecord>,
/// Every episode the source knows about (series only). The destination
/// waits until its scan has found all of them before anything is deleted.
/// Every episode the source knows about (series and seasons). The
/// destination waits until its scan has found all of them before anything
/// is deleted.
#[serde(default)]
pub episode_keys: Vec<ItemKey>,
/// Set for a season move. `rel_folder` and the manifest are then the
/// show's folder, holding only this season's folder and the show's own
/// loose files.
#[serde(default)]
pub season: Option<SeasonInfo>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SeasonInfo {
pub number: i32,
/// The season's folder inside the show folder, e.g. `Season 02`.
pub folder: String,
pub show_name: String,
/// The show's provider IDs (Tvdb, Tmdb, Imdb...), for finding the same
/// show on the destination.
#[serde(default)]
pub show_provider_ids: std::collections::HashMap<String, String>,
/// Manifest indexes of the show's own files (tvshow.nfo, artwork). Only
/// copied when the destination doesn't have the show yet.
pub show_files: Vec<usize>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
@@ -167,6 +198,14 @@ pub struct Job {
pub target_folder_jellyfin: Option<String>,
/// Item ID Jellyfin assigned on the destination after the scan.
pub target_item_id: Option<String>,
/// Destination library location (Jellyfin namespace) holding the target
/// folder. Missing on jobs from before v0.2.0.
#[serde(default)]
pub target_location: Option<String>,
/// Manifest indexes not to copy, e.g. a show's files when a season goes
/// into a show the destination already has.
#[serde(default)]
pub skip_files: Vec<usize>,
pub progress: Progress,
/// Human-readable log of what happened, newest last.
pub log: Vec<String>,
@@ -197,6 +236,8 @@ impl Job {
target_library: None,
target_folder_jellyfin: None,
target_item_id: None,
target_location: None,
skip_files: Vec::new(),
progress: Progress::default(),
log: Vec::new(),
}