Cotton code
369 lines · 24.1 KB · RustRaw
//! Cotton Cinemas' intake on this phone: a capture's rows, a series from a//! folder's names, duplicates and the better file, and the Mac's queue.use std::path::Path;use serde_json::json;use super::*;use crate::shell::client::phone_tests::attached;/// An invented film file in the test's folder: bytes that are no real film.fn invented(dir: &Path, name: &str, bytes: &[u8]) -> PathBuf {    let path = dir.join(name.replace('/', "_"));    std::fs::write(&path, bytes).expect("the file");    path}fn film_in(dir: &Path, source_path: &str, bytes: &[u8], read: Value) -> Value {    let mut asked = json!({ "path": invented(dir, source_path, bytes).to_string_lossy(), "sourcePath": source_path });    for (key, value) in read.as_object().expect("an object") {        asked[key] = value.clone();    }    asked}/// The capture as the app calls it: rows, then this phone keeping the files.fn captured(client: &ClientController, films: &[Value], only_films: bool) -> Value {    capture(client, &json!({ "films": films, "onlyFilms": only_films })).expect("a capture")}fn record(client: &ClientController, table: &str, id: &str) -> Value {    crate::phone::records::call(client, "records.get", &json!({"table": table, "id": id})).expect("the record")["data"].clone()}fn listed(client: &ClientController, table: &str) -> Vec<Value> {    crate::phone::records::call(client, "records.list", &json!({"table": table, "limit": 100})).expect("a list")["records"].as_array().cloned().unwrap_or_default()}fn outcomes(answer: &Value) -> Vec<String> {    answer["films"].as_array().expect("films").iter().map(|film| film["outcome"].as_str().unwrap_or_default().to_string()).collect()}const PLAYABLE: &str = r#"{"minutes": 101.4, "video": "avc1", "audio": "mp4a", "height": 1080, "bitrate": 4200}"#;// RULE (Cinemas definition, 4 Nov 2026, section 6): a playable MP4 goes up whole as `films/<id>/whole.mp4`, its `file`; an MKV goes up as it came, `films/<id>/source.mkv`, with needs_mac, and says it is converting on the Mac.#[test]fn a_playable_film_goes_up_whole_and_another_waits_for_the_mac() {    let (dir, client) = attached();    let films = [        film_in(dir.path(), "Night Ferry (2019).mp4", b"invented mp4 bytes", serde_json::from_str(PLAYABLE).unwrap()),        film_in(dir.path(), "Paper.Comets.2016.1080p.BluRay.x264.mkv", b"invented mkv bytes", json!({"minutes": 95.0, "video": "hevc", "audio": "dts"})),    ];    let answer = captured(&client, &films, false);    assert_eq!(outcomes(&answer), ["added", "added"], "{answer}");    let ferry = &answer["films"][0];    let id = ferry["id"].as_str().expect("an id");    assert_eq!(ferry["key"], json!(format!("{}/films/{id}/whole.mp4", crate::fixture::WORKSPACE)));    let row = record(&client, "film", id);    assert_eq!((row["title"].as_str(), row["year"].as_str(), row["kind"].as_str(), row["status"].as_str()), (Some("Night Ferry"), Some("2019"), Some("film"), Some("want_to_watch")));    assert_eq!(row["file"], ferry["key"]);    assert_eq!((row["minutes"].as_f64(), row["height"].as_f64()), (Some(101.0), Some(1080.0)));    assert_eq!(row["on_phone"], "kept", "brought in here, so on this phone");    let comets = &answer["films"][1];    let id = comets["id"].as_str().expect("an id");    assert_eq!(comets["key"], json!(format!("{}/films/{id}/source.mkv", crate::fixture::WORKSPACE)));    assert_eq!(comets["line"], "Paper Comets is converting on your Mac.");    let row = record(&client, "film", id);    assert_eq!((row["title"].as_str(), row["year"].as_str()), (Some("Paper Comets"), Some("2016")));    assert!(row.get("file").is_none_or(Value::is_null), "no stream until the Mac's lands: {row}");    assert_eq!((row["source_file"].clone(), row["needs_mac"].clone()), (comets["key"].clone(), json!(true)));    let queued = client.with_writer(|replica| Ok(cotton_store::media_ledger::media_by_key(replica.driver, comets["key"].as_str().unwrap()).ok().flatten())).expect("the ledger");    assert!(queued.is_some(), "queued to go up for the Mac");}// RULE: a folder's names make the series, its seasons and its episodes, once each; the same bytes again are already here.#[test]fn a_folder_of_episodes_makes_one_series_its_seasons_and_episodes() {    let (dir, client) = attached();    let films: Vec<Value> = [        ("Lowmarsh/Season 01/S01E01 - Reeds.mp4", "one"),        ("Lowmarsh/Season 01/S01E02 - Low Water.mp4", "two"),        ("Lowmarsh/Season 02/S02E01.mp4", "three"),    ]    .iter()    .map(|(path, bytes)| film_in(dir.path(), path, format!("invented episode {bytes}").as_bytes(), serde_json::from_str(PLAYABLE).unwrap()))    .collect();    let answer = captured(&client, &films, false);    assert_eq!(outcomes(&answer), ["added", "added", "added"], "{answer}");    assert_eq!(answer["said"], "Lowmarsh: 3 episodes came in.");    let series = listed(&client, "film");    assert_eq!(series.len(), 1, "one series: {series:?}");    assert!(answer["films"].as_array().expect("films").iter().all(|episode| episode["series"] == series[0]["id"]), "each episode names its series, where a folder lands: {answer}");    assert_eq!((series[0]["data"]["kind"].as_str(), series[0]["data"]["title"].as_str()), (Some("series"), Some("Lowmarsh")));    let seasons: Vec<(i64, String)> = listed(&client, "film_season").iter().map(|season| (season["data"]["number"].as_i64().unwrap_or_default(), season["data"]["title"].as_str().unwrap_or_default().to_string())).collect();    assert_eq!(seasons.len(), 2);    assert!(seasons.contains(&(1, "Season 1".into())) && seasons.contains(&(2, "Season 2".into())), "{seasons:?}");    let titles: Vec<String> = listed(&client, "film_episode").iter().map(|episode| episode["data"]["title"].as_str().unwrap_or_default().to_string()).collect();    assert!(titles.contains(&"Reeds".into()) && titles.contains(&"Low Water".into()) && titles.contains(&"Episode 1".into()), "{titles:?}");    let again = captured(&client, &films[..1], false);    assert_eq!(outcomes(&again), ["here"], "the same bytes are already here");    assert_eq!(again["films"][0]["table"], "film_episode", "the drain lands on the record it names");    assert_eq!(again["films"][0]["series"], series[0]["id"], "and on its series");}// RULE: the same title and year in a better file takes the held one's place under a fresh folder; a worse one is not kept; a locked file is refused and never opened.#[test]fn of_two_files_of_one_film_the_better_is_kept_and_a_locked_one_is_refused() {    let (dir, client) = attached();    let sd = film_in(dir.path(), "Night Ferry (2019).mp4", b"invented sd", json!({"video": "avc1", "audio": "mp4a", "height": 576}));    let first = captured(&client, &[sd], false);    let id = first["films"][0]["id"].as_str().expect("an id").to_string();    let hd = film_in(dir.path(), "Night.Ferry.2019.1080p.mp4", b"invented hd", json!({"video": "avc1", "audio": "mp4a", "height": 1080}));    let better = captured(&client, &[hd], false);    assert_eq!(outcomes(&better), ["better"], "{better}");    assert_eq!(better["films"][0]["id"], json!(id), "the same film row");    let key = better["films"][0]["key"].as_str().expect("its key");    assert_ne!(key, first["films"][0]["key"].as_str().unwrap(), "never the held file's key");    assert_eq!(record(&client, "film", &id)["file"], json!(key));    let worse = captured(&client, &[film_in(dir.path(), "Night Ferry (2019) cam.mp4", b"invented cam", json!({"title": "Night Ferry", "year": "2019", "video": "avc1", "audio": "mp4a", "height": 480}))], false);    assert_eq!(outcomes(&worse), ["worse"], "{worse}");    let locked = captured(&client, &[film_in(dir.path(), "Bought (2020).m4v", b"invented locked", json!({"locked": true}))], false);    assert_eq!(outcomes(&locked), ["refused"]);    assert_eq!(locked["films"][0]["line"], "Bought (2020).m4v is locked by its seller, and Cotton never takes a lock off.");}// RULE: in Cotton's own drain a short clip in a camera's container is no film (Photos keeps it); twenty minutes or an MKV is.#[test]fn cottons_drain_takes_only_films() {    let (dir, client) = attached();    let answer = captured(        &client,        &[            film_in(dir.path(), "IMG_0042.mov", b"invented clip", json!({"minutes": 1.5, "video": "hvc1", "audio": "mp4a"})),            film_in(dir.path(), "Home Movie.mkv", b"invented mkv", json!({"minutes": 3.0})),        ],        true,    );    assert_eq!(outcomes(&answer), ["not_film", "added"], "{answer}");}// RULE (Cinemas gaps, 5 Nov 2026): On this phone's top line counts what its list lists — the films kept, never a series, which holds no file — beside the episodes kept, and weighs the files brought in, byte for byte; every Cinemas tile counts the very list its deck reads.#[test]fn on_this_phone_counts_its_own_list_and_the_kept_bytes() {    let (dir, client) = attached();    let film: &[u8] = b"invented whole film bytes";    let (one, two): (&[u8], &[u8]) = (b"invented episode one", b"invented episode two, longer");    let films = [        film_in(dir.path(), "Night Ferry (2019).mp4", film, serde_json::from_str(PLAYABLE).unwrap()),        film_in(dir.path(), "Lowmarsh/Season 01/S01E01.mp4", one, serde_json::from_str(PLAYABLE).unwrap()),        film_in(dir.path(), "Lowmarsh/Season 01/S01E02.mp4", two, serde_json::from_str(PLAYABLE).unwrap()),    ];    assert_eq!(outcomes(&captured(&client, &films, false)), ["added", "added", "added"]);    let counted = crate::phone::films::on_phone_counts(&client).expect("the counts");    assert_eq!(counted, json!({"films": 1, "episodes": 2, "bytes": film.len() + one.len() + two.len()}), "the series is no film");    let views = crate::phone::tool_views::read(&client, &json!({"tool": "cinemas", "today": "2026-11-05", "timezone": "UTC"})).expect("the views");    let views = views["views"].as_array().expect("views");    assert!(views.iter().any(|view| view["id"] == "on_phone"), "{views:?}");    for view in views {        let mut request = view["read"].clone();        request["limit"] = json!(1);        let list = crate::phone::records::call(&client, "records.list", &request).expect("the deck's read");        assert_eq!(view["count"], list["total"], "{}", view["id"]);    }    let on_phone = views.iter().find(|view| view["id"] == "on_phone").expect("on_phone");    assert_eq!(on_phone["count"], 1, "the film it lists");}// RULE (walk 362, step 09): a film brought in from this phone is on this phone — the same bytes again after a reinstall (the row back from the object, nothing kept here) are kept here as the film's whole file, never uploaded again.#[test]fn the_same_film_brought_in_again_is_on_this_phone() {    let (dir, client) = attached();    let bytes: &[u8] = b"invented clip bytes";    let first = captured(&client, &[film_in(dir.path(), "Walk Clip (2024).mp4", bytes, serde_json::from_str(PLAYABLE).unwrap())], false);    let key = first["films"][0]["key"].as_str().expect("a key").to_string();    // A reinstall: the row stands (the object's), nothing of it is on this phone.    std::fs::remove_file(client.layout().client_dir().join(crate::phone::films::FILE)).expect("films-here is written");    client.with_writer(|f| f.driver.run("DELETE FROM _media WHERE key = ?", &[rusqlite::types::Value::Text(key.clone())]).map(|_| ()).map_err(|error| error.to_string())).unwrap();    assert_eq!(crate::phone::films::on_phone_counts(&client).unwrap()["films"], 0);    let again = captured(&client, &[film_in(dir.path(), "Walk Clip again.mp4", bytes, serde_json::from_str(PLAYABLE).unwrap())], false);    assert_eq!(outcomes(&again), ["here"], "{again}");    assert_eq!(again["films"][0]["key"], json!(key), "its whole file is these bytes");    assert_eq!(crate::phone::films::on_phone_counts(&client).unwrap()["films"], 1, "On this phone lists it");    let row = client.with_writer(|f| cotton_store::media_ledger::media_by_key(f.driver, &key).map_err(|error| error.to_string())).unwrap().expect("its ledger row");    assert_eq!(row.state, "synced", "the object holds it: nothing goes up again");    assert!(row.local_path.is_some(), "its bytes are here");}// ── what lies beside a film (the shared fixture, cotton-core's tests/fixtures/film_sidecars.json) ──fn fixture() -> Value {    let text = std::fs::read_to_string(std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").expect("cargo sets CARGO_MANIFEST_DIR")).join("../cotton-core/tests/fixtures/film_sidecars.json")).expect("the shared fixture");    serde_json::from_str(&text).expect("the fixture is JSON")}fn nfo_text(fixture: &Value, name: &str) -> String {    fixture["nfo"].as_array().expect("nfo").iter().find(|nfo| nfo["name"] == name).expect("the fixture's NFO")["text"].as_str().expect("its text").to_string()}/// A folder as the phone hands it: every name, the NFOs' text, and an/// invented copy of each subtitle and picture among `staged`.fn folder(dir: &Path, siblings: &[&str], nfos: &[(&str, String)], staged: &[&str]) -> Value {    let files: serde_json::Map<String, Value> = staged.iter().map(|name| (name.to_string(), json!(invented(dir, &format!("staged {name}"), format!("invented {name}").as_bytes()).to_string_lossy()))).collect();    json!({ "siblings": siblings, "nfos": nfos.iter().map(|(name, text)| (name.to_string(), json!(text))).collect::<serde_json::Map<_, _>>(), "files": files })}fn ledger(client: &ClientController, key: &str) -> Option<cotton_store::media_ledger::MediaRow> {    client.with_writer(|f| cotton_store::media_ledger::media_by_key(f.driver, key).map_err(|error| error.to_string())).expect("the ledger")}fn filled_from(row: &Value) -> Value {    serde_json::from_str(row["filled_from"].as_str().unwrap_or("{}")).expect("filled_from is JSON")}/// Night Ferry's folder from the fixture, two of its subtitles staged.fn night_ferry(dir: &Path, fixture: &Value) -> Value {    let case = &fixture["sidecars"][0];    let siblings: Vec<&str> = case["siblings"].as_array().expect("siblings").iter().filter_map(Value::as_str).filter(|name| !name.contains(".English.") && !name.ends_with(".fr.ass") && *name != "Night Ferry (2019).srt").collect();    folder(dir, &siblings, &[("Night Ferry (2019).nfo", nfo_text(fixture, "movie"))], &["Night Ferry (2019).en.srt", "Night Ferry (2019).hin.forced.srt", "poster.jpg", "fanart.jpg"])}// RULE (open standards, 7 Nov 2026): a film's NFO fills only empty columns, ids first, said in filled_from as nfo, and its title beats the file's name; the poster and fanart beside it are its poster and backdrop; each subtitle is kept in the film's own folder beside its file, named so the rules read it back, queued and pinned; chapters handed in are its chapters.#[test]fn a_film_takes_its_nfo_poster_fanart_and_subtitles() {    let (dir, client) = attached();    let fixture = fixture();    let chapters = json!([{"startMs": 0, "title": "Harbour"}, {"start_ms": 600000, "title": "Open Water"}]);    let film = film_in(dir.path(), "Night Ferry (2019).mkv", b"invented ferry mkv", json!({"minutes": 101.0, "beside": night_ferry(dir.path(), &fixture), "chapters": chapters}));    let answer = captured(&client, &[film], false);    assert_eq!(outcomes(&answer), ["added"], "{answer}");    let made = &answer["films"][0];    let id = made["id"].as_str().expect("an id");    let row = record(&client, "film", id);    assert_eq!((row["title"].as_str(), row["year"].as_str(), row["original_title"].as_str()), (Some("Night Ferry"), Some("2019"), Some("Nachtfähre")));    assert_eq!((row["tmdb_id"].as_str(), row["imdb_id"].as_str(), row["tvdb_id"].as_str()), (Some("900101"), Some("tt0000101"), Some("5501")));    assert_eq!(row["synopsis"], "A ferry crosses at night & nobody sleeps.");    assert_eq!(row["minutes"].as_f64(), Some(101.0), "the file's own length stays: the NFO fills only what is empty");    let from = filled_from(&row);    assert_eq!((from["title"].as_str(), from["tmdb_id"].as_str()), (Some("nfo"), Some("nfo")), "{from}");    assert!(from.get("minutes").is_none(), "{from}");    assert!(row["poster"].as_str().is_some_and(|key| key.contains("/photos/")), "the poster beside it: {row}");    assert!(row["backdrop"].as_str().is_some_and(|key| key.contains("/photos/")), "the fanart beside it: {row}");    assert_ne!(row["poster"], row["backdrop"]);    let stored: Value = serde_json::from_str(row["chapters"].as_str().expect("chapters")).expect("chapters are JSON");    assert_eq!(stored, json!([{"start_ms": 0, "title": "Harbour"}, {"start_ms": 600000, "title": "Open Water"}]), "the Mac's shape");    let folder = format!("{}/films/{id}", crate::fixture::WORKSPACE);    assert_eq!(made["subtitles"], json!([format!("{folder}/source.en.srt"), format!("{folder}/source.hin.forced.srt")]), "Hindi as hin: a bare hi is the hearing-impaired mark: {answer}");    for key in made["subtitles"].as_array().expect("subtitles") {        let row = ledger(&client, key.as_str().unwrap()).expect("queued to go up");        assert!(row.pinned, "on this phone: {key}");    }    // The rules read the kept names back beside the file.    let names: Vec<String> = made["subtitles"].as_array().unwrap().iter().map(|key| key.as_str().unwrap().rsplit('/').next().unwrap().to_string()).collect();    let back = cotton_core::films::sidecars::sidecars("source.mkv", &names, false);    assert_eq!(back.subtitles.iter().map(|s| (s.language.as_str(), s.forced)).collect::<Vec<_>>(), [("en", false), ("hi", true)]);}// RULE: an episode takes its own NFO and no folder art; its series' folder (tvshow.nfo, poster, fanart) fills the series row's empty columns once.#[test]fn an_episode_takes_its_own_nfo_and_its_series_folder_dresses_the_series() {    let (dir, client) = attached();    let fixture = fixture();    let case = &fixture["sidecars"][3];    let siblings: Vec<&str> = case["siblings"].as_array().unwrap().iter().filter_map(Value::as_str).collect();    let own = folder(dir.path(), &siblings, &[("S02E05 - The Long Night.nfo", nfo_text(&fixture, "episode"))], &["S02E05 - The Long Night.eng.srt"]);    let series_siblings: Vec<&str> = fixture["series"][0]["siblings"].as_array().unwrap().iter().filter_map(Value::as_str).collect();    let series = folder(dir.path(), &series_siblings, &[("tvshow.nfo", nfo_text(&fixture, "tvshow"))], &["poster.png", "fanart.jpg"]);    let episode = film_in(dir.path(), case["video"].as_str().unwrap(), b"invented episode", json!({"video": "hevc", "audio": "aac", "beside": own, "seriesBeside": series}));    let answer = captured(&client, &[episode], false);    assert_eq!(outcomes(&answer), ["added"], "{answer}");    let made = &answer["films"][0];    let row = record(&client, "film_episode", made["id"].as_str().unwrap());    assert_eq!((row["title"].as_str(), row["aired"].as_str(), row["tvdb_id"].as_str(), row["tmdb_id"].as_str()), (Some("The Long Night"), Some("2022-10-14"), Some("9900105"), Some("7700105")));    assert_eq!((row["synopsis"].as_str(), row["minutes"].as_f64()), (Some("The water rises & the bell rings."), Some(48.0)));    let said = filled_from(&row);    assert_eq!((said["tvdb_id"].as_str(), said["title"].as_str()), (Some("nfo"), Some("nfo")), "an episode's fills are said: {row}");    assert!(row.get("still").is_none_or(Value::is_null), "an episode takes no folder art: {row}");    let id = made["id"].as_str().unwrap();    assert_eq!(made["subtitles"], json!([format!("{}/films/{id}/source.en.srt", crate::fixture::WORKSPACE)]));    let series = record(&client, "film", made["series"].as_str().expect("its series"));    assert_eq!(series["title"], "Lowmarsh", "the series' name stays");    assert_eq!((series["synopsis"].as_str(), series["tvdb_id"].as_str(), series["year"].as_str()), (Some("A town under water."), Some("440011"), Some("2021")));    assert!(series["poster"].as_str().is_some() && series["backdrop"].as_str().is_some(), "{series}");    assert_eq!(filled_from(&series)["tvdb_id"], "nfo");}// RULE (the Mac's rule, a1481ff57): a title the person typed beats the NFO's and the name's; the NFO still fills the rest.#[test]fn a_typed_title_beats_the_nfo() {    let (dir, client) = attached();    let fixture = fixture();    let film = film_in(dir.path(), "Night Ferry (2019).mkv", b"invented ferry", json!({"typedTitle": "My Ferry", "beside": night_ferry(dir.path(), &fixture)}));    let answer = captured(&client, &[film], false);    assert_eq!(answer["films"][0]["title"], "My Ferry", "{answer}");    let row = record(&client, "film", answer["films"][0]["id"].as_str().unwrap());    assert_eq!((row["title"].as_str(), row["year"].as_str(), row["tmdb_id"].as_str()), (Some("My Ferry"), Some("2019"), Some("900101")));    let from = filled_from(&row);    assert!(from.get("title").is_none(), "the typed title is the person's: {from}");}// RULE: a bare video is what it was; a sidecar the rules name but the phone did not hand refuses the capture; an NFO that is no NFO is named, never read.#[test]fn a_bare_video_is_unchanged_and_a_missing_sidecar_is_refused() {    let (dir, client) = attached();    let fixture = fixture();    let bare = captured(&client, &[film_in(dir.path(), "Paper Comets (2016).mp4", b"invented bare", serde_json::from_str(PLAYABLE).unwrap())], false);    let made = &bare["films"][0];    assert!(made.get("subtitles").is_none() && made.get("nfoUnread").is_none(), "{bare}");    let row = record(&client, "film", made["id"].as_str().unwrap());    assert_eq!(row["title"], "Paper Comets");    for column in ["filled_from", "backdrop", "chapters", "tmdb_id", "poster"] {        assert!(row.get(column).is_none_or(Value::is_null), "{column}: {row}");    }    let unhanded = folder(dir.path(), &["Dust Signals.mp4", "Dust Signals.en.srt"], &[], &[]);    let refused = capture(&client, &json!({"films": [film_in(dir.path(), "Dust Signals.mp4", b"invented dust", json!({"beside": unhanded}))]})).expect_err("refused");    assert_eq!(refused.code, "bad_request");    assert!(refused.message.contains("Dust Signals.en.srt"), "{}", refused.message);    let not_nfo = folder(dir.path(), &["Dust Signals.mp4", "MOVIE.NFO"], &[("MOVIE.NFO", nfo_text(&fixture, "not an nfo"))], &[]);    let answer = captured(&client, &[film_in(dir.path(), "Dust Signals.mp4", b"invented dust", json!({"beside": not_nfo}))], false);    assert_eq!(answer["films"][0]["nfoUnread"], json!(["MOVIE.NFO"]), "{answer}");    assert_eq!(record(&client, "film", answer["films"][0]["id"].as_str().unwrap())["title"], "Dust Signals");}#[test]fn a_picked_folder_says_its_films_and_the_sidecars_to_stage() {    let answer = picked(&json!({ "paths": [        "Picked/Night Ferry/tvshow.nfo",        "Picked/Night Ferry/poster.jpg",        "Picked/Night Ferry/Season 02/S02E05 - The Long Night.mkv",        "Picked/Night Ferry/Season 02/S02E05 - The Long Night.en.srt",        "Picked/Night Ferry/Season 02/notes.txt",        "Picked/The Fog Bell (2021).mp4",        "Picked/The Fog Bell (2021).nfo",        "Picked/fanart.png",    ] }))    .expect("an answer");    assert_eq!(        answer["films"],        json!([            { "path": "Picked/Night Ferry/Season 02/S02E05 - The Long Night.mkv", "series": "Picked/Night Ferry" },            { "path": "Picked/The Fog Bell (2021).mp4", "series": null },        ])    );    assert_eq!(        answer["stage"],        json!([            "Picked/Night Ferry/Season 02/S02E05 - The Long Night.en.srt",            "Picked/Night Ferry/poster.jpg",            "Picked/Night Ferry/tvshow.nfo",            "Picked/The Fog Bell (2021).nfo",            "Picked/fanart.png",        ]),        "only what a capture will ask for: never notes.txt"    );}// RULE (android-finish's Cinemas walk, 25 Nov 2026): a folder of episodes that all wait for the Mac says so once, never a// sentence per episode.#[test]fn a_folder_of_episodes_for_the_mac_says_so_once() {    let (dir, client) = attached();    let unplayable = r#"{"minutes": 44.0, "video": "hvc1", "audio": "ac-3", "height": 1080, "bitrate": 4200}"#;    let films: Vec<Value> = ["Lowmarsh/Season 01/S01E01.mkv", "Lowmarsh/Season 01/S01E02.mkv"]        .iter()        .map(|path| film_in(dir.path(), path, format!("invented episode {path}").as_bytes(), serde_json::from_str(unplayable).unwrap()))        .collect();    let answer = captured(&client, &films, false);    assert!(answer["films"].as_array().unwrap().iter().all(|film| film["needsMac"] == true), "{answer}");    assert_eq!(answer["said"], "Lowmarsh: 2 episodes are converting on your Mac.");}