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:
1 parent
25a743b350
commit
484ac50508
21 files changed
+959
-111
No files matched your search
@@ -29,6 +29,20 @@ pub struct LibraryItem {
|
||||
pub size: Option<FolderSize>,
|
||||
}
|
||||
|
||||
/// A season of a show, as Jellyfin lists it.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SeasonItem {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub number: Option<i32>,
|
||||
/// The season's own folder. `None` when its episodes sit directly in the
|
||||
/// show folder, in which case it can't be moved on its own.
|
||||
pub path: Option<String>,
|
||||
/// Name of that folder inside the show folder, to match it with the
|
||||
/// show's per-folder sizes.
|
||||
pub folder: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct LocationCheck {
|
||||
pub library: String,
|
||||
@@ -103,6 +117,41 @@ pub async fn items(
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The seasons of a show, in order. Seasons without a folder of their own
|
||||
/// inside the show folder are listed with no path.
|
||||
pub async fn seasons(state: &AppState, series_id: &str) -> anyhow::Result<Vec<SeasonItem>> {
|
||||
let series = state.jellyfin.item(series_id).await?;
|
||||
let show = series.path.map(PathBuf::from);
|
||||
let mut out: Vec<SeasonItem> = state
|
||||
.jellyfin
|
||||
.items(&ItemQuery {
|
||||
parent_id: Some(series_id),
|
||||
include_types: &["Season"],
|
||||
..Default::default()
|
||||
})
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|s| {
|
||||
let path = s
|
||||
.path
|
||||
.filter(|p| show.as_deref().is_some_and(|show| Path::new(p).parent() == Some(show)));
|
||||
let folder = path
|
||||
.as_deref()
|
||||
.and_then(|p| Path::new(p).file_name())
|
||||
.map(|n| n.to_string_lossy().into_owned());
|
||||
SeasonItem {
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
number: s.index_number,
|
||||
path,
|
||||
folder,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
out.sort_by_key(|s| s.number.unwrap_or(i32::MAX));
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The folder a move would take, as this agent sees it: a movie's parent
|
||||
/// folder, or the series folder itself.
|
||||
fn item_folder(state: &AppState, item: &LibraryItem) -> Option<PathBuf> {
|
||||
|
||||
Reference in new issue
Block a user