Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

YouTube: tell yt-dlp about Node.js or Bun, retry a refused look-up, say when ffmpeg is missing (#360, #352, #351) (#369)

Ahmed Nefzaoui840315991552
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb2ef43d..b58b77a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,9 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- **YouTube formats with Node.js or Bun installed** ([#360](https://github.com/anefzaoui/misterdownloadmanager/issues/360)): yt-dlp needs a JavaScript runtime for them and looks for Deno alone, so MDM now tells it about Node.js (nvm's too) or Bun when there is no Deno.
+- **YouTube's look-up failing with "Requested format is not available"** ([#352](https://github.com/anefzaoui/misterdownloadmanager/issues/352)): signed-in cookies make yt-dlp use only YouTube's players that need a JavaScript runtime, and without one no video is left. The page is now looked up again without the cookies, and lists its qualities.
+- **Download video offering only the sound, with no reason given** ([#351](https://github.com/anefzaoui/misterdownloadmanager/issues/351)): when a page's better videos need ffmpeg and it isn't installed, the window now says so.
- Adding a link again after its finished file was moved or deleted starts a new download, instead of asking about a duplicate that isn't there ([#342](https://github.com/anefzaoui/misterdownloadmanager/issues/342)).
## [0.5.1] - 2026-11-08
diff --git a/ROADMAP.md b/ROADMAP.md
index 14b14525..5b7fd79c 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -98,6 +98,9 @@ Everything below ships together, in version 0.5.0.
([#192](https://github.com/anefzaoui/misterdownloadmanager/issues/192))
- ✅ A menu of the menu bar shut with Escape opens again at the first click on its title (on
Linux it took two; on Windows, Escape with the pointer on the title left the menu open)
+- ✅ A YouTube look-up that fails with "Requested format is not available" (signed in, no
+ JavaScript runtime for yt-dlp) tries once more without the cookies; the video window says when
+ ffmpeg would bring the better qualities a page offers
- ✅ Signed-in videos from YouTube Music and YouTube's mobile site: the browser's cookies reach
the YouTube host yt-dlp asks, each for the domain the browser keeps it for
([#229](https://github.com/anefzaoui/misterdownloadmanager/issues/229))
diff --git a/crates/app/src/app.rs b/crates/app/src/app.rs
index 43f78907..ed9b2acb 100644
--- a/crates/app/src/app.rs
+++ b/crates/app/src/app.rs
@@ -1873,6 +1873,13 @@ impl App {
}
}
}
+ // A page whose videos need ffmpeg (#351): without it the list has only the sound.
+ "video-adaptive" => {
+ self.run(Cmd::VideoPage, None, ctx);
+ if let Some(v) = &mut self.video_dlg {
+ v.show_sample_adaptive();
+ }
+ }
// A sample playlist (#69), its quality by its place in the list: `video-playlist:7`.
"video-playlist" => {
self.run(Cmd::VideoPage, None, ctx);
diff --git a/crates/app/src/videodlg.rs b/crates/app/src/videodlg.rs
index 7d334003..1f4494b6 100644
--- a/crates/app/src/videodlg.rs
+++ b/crates/app/src/videodlg.rs
@@ -249,6 +249,22 @@ impl VideoDialog {
}
}
+ /// A page like YouTube's when yt-dlp has no JavaScript runtime (#351): videos and sound
+ /// apart, nothing carrying both (`/show video-adaptive`).
+ pub fn show_sample_adaptive(&mut self) {
+ const SAMPLE: &str = r#"{"title": "A conference talk about download managers, recorded in Lisbon",
+ "duration": 1830, "language": "en", "formats": [
+ {"format_id": "140", "ext": "m4a", "vcodec": "none", "acodec": "mp4a", "filesize": 29000000},
+ {"format_id": "137", "ext": "mp4", "height": 1080, "vcodec": "avc1", "acodec": "none", "filesize": 412000000},
+ {"format_id": "136", "ext": "mp4", "height": 720, "vcodec": "avc1", "acodec": "none", "filesize": 201000000}]}"#;
+ if let Some(v) = mdm_tools::resolve::parse(SAMPLE.as_bytes()) {
+ self.page = "https://video.example/talk".into();
+ self.looked_up = self.page.clone();
+ self.auto_look = false;
+ self.set_video(v);
+ }
+ }
+
/// A listed playlist, as [`crate::playlistdlg::PlaylistView::sample`] makes it, its quality
/// the one at position `pick` (`/show video-playlist:7`).
pub fn show_sample_list(&mut self, pick: &str) {
@@ -562,6 +578,15 @@ impl VideoDialog {
winui::buttons_to_right(&p, 489.0, 8.0, &[(label, 90.0)], 200.0)[0]
});
let status_right = install_at.map_or(489.0, |(x, _)| x - 9.0);
+ // #351: a page whose better videos need ffmpeg says so in place of its title (still in
+ // File name): YouTube without a JavaScript runtime leaves nothing but the sound to offer
+ // here, and the list alone gives no reason.
+ let merge_note = self
+ .video
+ .as_ref()
+ .filter(|(v, _)| ffmpeg.is_none() && mdm_tools::resolve::needs_merging(v))
+ .and(offer.as_ref())
+ .map(|(_, _, msg)| *msg);
if let Some(t) = installing {
crate::torrentdlg::spinner(ui, pos2(o.x + 18.0, line_y - 4.0), 6.0);
let msg = if t == Tool::YtDlp {
@@ -581,6 +606,17 @@ impl VideoDialog {
);
} else if self.list.is_some() {
// The list draws its own (PlaylistView::middle).
+ } else if let Some(msg) = merge_note {
+ winui::fit(
+ ui,
+ &p,
+ o.x + 11.0,
+ line_y,
+ msg,
+ winui::MUTED(),
+ o.x + status_right,
+ "video-offer",
+ );
} else if let Some((v, _)) = &self.video {
let (rect, cut) = winui::text_fit(
&p,
diff --git a/crates/tools/src/proc.rs b/crates/tools/src/proc.rs
index edc2537f..54fbf37a 100644
--- a/crates/tools/src/proc.rs
+++ b/crates/tools/src/proc.rs
@@ -136,15 +136,82 @@ pub fn browser_cookies() -> Option<BrowserCookies> {
/// store is read only when nothing came: a pasted address, a link typed into Add URL, a
/// playlist listed later. yt-dlp would merge the two if given both; it never is.
fn browser_cookie_args(args: &[String], chosen: Option<&BrowserCookies>) -> Vec<String> {
- let has_cookies = args
+ let settled = args
.iter()
- .any(|a| a == "--cookies" || a == "--cookies-from-browser");
+ .any(|a| a == "--cookies" || a == "--cookies-from-browser" || a == NO_COOKIES);
match chosen {
- Some(c) if !has_cookies => vec!["--cookies-from-browser".into(), c.spec()],
+ Some(c) if !settled => vec!["--cookies-from-browser".into(), c.spec()],
_ => Vec::new(),
}
}
+/// yt-dlp's "no cookies from any browser": a run told this gets none of the chosen browser's.
+const NO_COOKIES: &str = "--no-cookies-from-browser";
+
+/// `ours` for a look-up without cookies (#352): the cookie file taken out, the browser's store
+/// refused.
+fn without_cookies(ours: &[String]) -> Vec<String> {
+ let mut out = Vec::with_capacity(ours.len() + 1);
+ let mut args = ours.iter();
+ while let Some(a) = args.next() {
+ if a == "--cookies" || a == "--cookies-from-browser" {
+ args.next();
+ } else {
+ out.push(a.clone());
+ }
+ }
+ out.push(NO_COOKIES.to_owned());
+ out
+}
+
+/// Does a run with arguments `ours` have cookies (its own, or the chosen browser's)?
+fn with_cookies(ours: &[String], chosen: Option<&BrowserCookies>) -> bool {
+ chosen.is_some()
+ || ours
+ .iter()
+ .any(|a| a == "--cookies" || a == "--cookies-from-browser")
+}
+
+/// A page's `-J` output, and whether it took looking the page up without cookies.
+pub struct LookedUp {
+ pub json: Vec<u8>,
+ pub without_cookies: bool,
+}
+
+/// Look a page up (`yt-dlp -J`, `ours` holding its arguments). yt-dlp's `-J` chooses a format too,
+/// and fails when none is left. Signed-in cookies make that likely on YouTube (#352): yt-dlp then
+/// asks only the players that need a JavaScript runtime to decode their links, and without one
+/// (it looks for Deno alone) every video is dropped: "Requested format is not available". The
+/// same page without the cookies lists its qualities, so a look-up that fails this way and had
+/// cookies is made once more without them; if that fails too, the first error is the one told.
+pub fn look_up(
+ exe: &Path,
+ ours: &[String],
+ url: &str,
+ timeout: Duration,
+) -> Result<LookedUp, ProcError> {
+ let run = |args: &[String]| output(ytdlp(exe, &[], args, url)?, "yt-dlp", timeout);
+ match run(ours) {
+ Ok(json) => Ok(LookedUp {
+ json,
+ without_cookies: false,
+ }),
+ Err(first)
+ if with_cookies(ours, browser_cookies().as_ref())
+ && crate::servers::format_unavailable(&first.to_string()) =>
+ {
+ match run(&without_cookies(ours)) {
+ Ok(json) => Ok(LookedUp {
+ json,
+ without_cookies: true,
+ }),
+ Err(_) => Err(first),
+ }
+ }
+ Err(e) => Err(e),
+ }
+}
+
/// Does yt-dlp's `WARNING:` (or `ERROR:`) line say it couldn't read the browser's cookies?
/// Kept on the failure's message (`Spawned::failure`), where `lookup_error` names it.
pub fn cookie_trouble(line: &str) -> bool {
@@ -488,6 +555,57 @@ fn layers_with(
Ok(())
}
+/// The file named `name` (`name.exe` on Windows) in one of `dirs`.
+fn program_in(dirs: &[PathBuf], name: &str) -> Option<PathBuf> {
+ let file = format!("{name}{}", std::env::consts::EXE_SUFFIX);
+ dirs.iter().map(|d| d.join(&file)).find(|p| p.is_file())
+}
+
+/// Node.js from nvm (`~/.nvm/versions/node/<version>/bin/node`), the newest name first: a program
+/// started from the desktop doesn't have nvm's folders on its PATH (#360).
+fn nvm_node(home: &Path) -> Option<PathBuf> {
+ let mut versions: Vec<PathBuf> = std::fs::read_dir(home.join(".nvm/versions/node"))
+ .ok()?
+ .flatten()
+ .map(|e| e.path().join("bin"))
+ .collect();
+ versions.sort();
+ versions.reverse();
+ program_in(&versions, "node")
+}
+
+/// What yt-dlp should be told about JavaScript (#360, #352, #351): YouTube's formats need a
+/// runtime, and yt-dlp looks for Deno alone unless told of another. Deno found: nothing to say.
+/// Else Node.js or Bun, if there is one.
+fn js_runtime(dirs: &[PathBuf], home: Option<&Path>) -> Option<(&'static str, PathBuf)> {
+ if program_in(dirs, "deno").is_some() {
+ return None;
+ }
+ program_in(dirs, "node")
+ .or_else(|| home.and_then(nvm_node))
+ .map(|p| ("node", p))
+ .or_else(|| program_in(dirs, "bun").map(|p| ("bun", p)))
+}
+
+/// `--js-runtimes` for this computer's Node.js or Bun, looked for once.
+fn js_runtime_args() -> &'static [String] {
+ static ARGS: std::sync::OnceLock<Vec<String>> = std::sync::OnceLock::new();
+ ARGS.get_or_init(|| {
+ let dirs: Vec<PathBuf> = std::env::var_os("PATH")
+ .map(|p| std::env::split_paths(&p).collect())
+ .unwrap_or_default();
+ let home = std::env::var_os("HOME").map(PathBuf::from);
+ js_runtime(&dirs, home.as_deref())
+ .map(|(name, path)| {
+ vec![
+ "--js-runtimes".to_owned(),
+ format!("{name}:{}", path.display()),
+ ]
+ })
+ .unwrap_or_default()
+ })
+}
+
/// `yt-dlp` with arguments in layers: `user` extras, then `ours` (then the chosen browser's
/// cookies when neither brought any, [`layers`]), then the fixed ones last (so nothing can
/// switch them off), then `--` and the URL (so a URL starting with `-` is never read as an
@@ -502,6 +620,7 @@ pub fn ytdlp(
let route = through_adapter(&mut cmd, Helper::YtDlp)?;
layers(&mut cmd, user, ours)?;
cmd.args(["--ignore-config", "--no-exec", "--no-update"]);
+ cmd.args(js_runtime_args());
cmd.args(UTF8);
cmd.args(route);
cmd.arg("--");
@@ -521,6 +640,7 @@ pub fn ytdlp_info(
let route = through_adapter(&mut cmd, Helper::YtDlp)?;
layers(&mut cmd, user, ours)?;
cmd.args(["--ignore-config", "--no-exec", "--no-update"]);
+ cmd.args(js_runtime_args());
cmd.args(UTF8);
cmd.args(route);
cmd.arg("--load-info-json");
@@ -941,6 +1061,63 @@ mod tests {
);
}
+ /// #360: yt-dlp is told of Node.js or Bun, from the PATH or nvm, and left alone with Deno.
+ #[test]
+ fn the_javascript_runtime_yt_dlp_is_told_of() {
+ let touch = |dir: &Path, name: &str| {
+ std::fs::create_dir_all(dir).unwrap();
+ std::fs::write(
+ dir.join(format!("{name}{}", std::env::consts::EXE_SUFFIX)),
+ b"",
+ )
+ .unwrap();
+ };
+ let root = tempfile::tempdir().unwrap();
+ let (path, home) = (root.path().join("bin"), root.path().join("home"));
+ let dirs = vec![path.clone()];
+ std::fs::create_dir_all(&path).unwrap();
+ assert_eq!(js_runtime(&dirs, Some(&home)), None);
+ for v in ["v20.1.0", "v22.3.0"] {
+ touch(&home.join(".nvm/versions/node").join(v).join("bin"), "node");
+ }
+ let (name, found) = js_runtime(&dirs, Some(&home)).unwrap();
+ assert_eq!(name, "node");
+ assert!(found.to_string_lossy().contains("v22.3.0"));
+ touch(&path, "bun");
+ assert_eq!(js_runtime(&dirs, None).unwrap().0, "bun");
+ touch(&path, "node");
+ assert_eq!(
+ js_runtime(&dirs, None).unwrap().1,
+ path.join(format!("node{}", std::env::consts::EXE_SUFFIX))
+ );
+ touch(&path, "deno");
+ assert_eq!(js_runtime(&dirs, Some(&home)), None);
+ }
+
+ /// #352: the second look-up has no cookies of any kind, and everything else the first had.
+ #[test]
+ fn a_look_up_without_cookies_keeps_the_rest() {
+ let ours: Vec<String> = [
+ "-J",
+ "--cookies",
+ "/tmp/c.txt",
+ "--referer",
+ "https://p.test/",
+ ]
+ .map(String::from)
+ .to_vec();
+ assert_eq!(
+ without_cookies(&ours),
+ ["-J", "--referer", "https://p.test/", NO_COOKIES]
+ );
+ let firefox = BrowserCookies::new("firefox", "").unwrap();
+ assert!(with_cookies(&ours, None));
+ assert!(with_cookies(&["-J".to_owned()], Some(&firefox)));
+ assert!(!with_cookies(&["-J".to_owned()], None));
+ // Told so, the chosen browser's cookies aren't read either.
+ assert_eq!(yt(Some(&firefox), &["-J", NO_COOKIES]), ["-J", NO_COOKIES]);
+ }
+
/// #229: why the browser's cookies didn't help stays on the failure's message.
#[test]
fn the_cookie_trouble_is_kept_on_the_failure() {
@@ -997,10 +1174,14 @@ mod tests {
"-https://x/",
)
.unwrap();
- let args: Vec<String> = cmd
+ let mut args: Vec<String> = cmd
.get_args()
.map(|a| a.to_string_lossy().into_owned())
.collect();
+ // This computer's Node.js or Bun, if it has one (#360); tested on its own below.
+ if let Some(i) = args.iter().position(|a| a == "--js-runtimes") {
+ args.drain(i..=i + 1);
+ }
assert_eq!(
args,
[
diff --git a/crates/tools/src/resolve.rs b/crates/tools/src/resolve.rs
index d342d65e..16d783e1 100644
--- a/crates/tools/src/resolve.rs
+++ b/crates/tools/src/resolve.rs
@@ -246,9 +246,8 @@ pub fn look_up(exe: &Path, url: &str, browser: &proc::FromBrowser) -> Result<Loo
// Kept until yt-dlp has answered.
let (theirs, _cookies) = browser.args(url)?;
args.extend(theirs);
- let cmd = proc::ytdlp(exe, &[], &args, url)?;
- let out = proc::output(cmd, "yt-dlp", Duration::from_secs(90))?;
- parse_looked(&out).ok_or_else(|| ProcError::Failed {
+ let out = proc::look_up(exe, &args, url, Duration::from_secs(90))?;
+ parse_looked(&out.json).ok_or_else(|| ProcError::Failed {
tool: "yt-dlp".into(),
message: "it gave no video information".into(),
})
@@ -346,6 +345,20 @@ pub fn holds_subtitles(c: &Choice) -> bool {
)
}
+/// Would merging (ffmpeg) bring a better video than the ones already carrying their sound (#351)?
+/// YouTube's only such format is 360p, and without a JavaScript runtime yt-dlp often has none:
+/// the list then holds the sound alone, so the window must say why.
+pub fn needs_merging(v: &Video) -> bool {
+ let best = |merging: bool| {
+ v.formats
+ .iter()
+ .filter(|f| f.video && (merging || f.audio))
+ .filter_map(|f| f.height)
+ .max()
+ };
+ best(true) > best(false)
+}
+
/// The choices, best first: each resolution (merged with the best audio when ffmpeg is there,
/// else only formats that carry both), then audio only.
pub fn choices(v: &Video, can_merge: bool) -> Vec<Choice> {
@@ -569,6 +582,66 @@ mod tests {
assert_eq!(plain[0].selector, "b[height=360]");
}
+ /// Live (#352): `MDM_LIVE_YTDLP=<yt-dlp> MDM_LIVE_PAGE=<video page> cargo test -p mdm-tools
+ /// live_look_up -- --ignored --nocapture`. A look-up given cookies; with a yt-dlp that fails
+ /// the way a signed-in session does (a wrapper forcing `web_embedded,tv_samsung,web` when it
+ /// sees `--cookies`), the second look-up, without them, lists the page's videos.
+ #[test]
+ #[ignore]
+ fn live_look_up_with_cookies() {
+ let exe =
+ std::path::PathBuf::from(std::env::var("MDM_LIVE_YTDLP").expect("MDM_LIVE_YTDLP"));
+ let page = std::env::var("MDM_LIVE_PAGE").expect("MDM_LIVE_PAGE");
+ let browser = proc::FromBrowser {
+ cookies: Some("YSC=test".into()),
+ ..Default::default()
+ };
+ let (mut args, _file) = browser.args(&page).unwrap();
+ args.insert(0, "-J".to_owned());
+ args.push("--no-playlist".to_owned());
+ let out = proc::look_up(&exe, &args, &page, Duration::from_secs(120)).unwrap();
+ let v = parse(&out.json).unwrap();
+ let heights: std::collections::BTreeSet<u32> = v
+ .formats
+ .iter()
+ .filter(|f| f.video)
+ .filter_map(|f| f.height)
+ .collect();
+ println!(
+ "without_cookies: {}, {} formats, video heights {heights:?}",
+ out.without_cookies,
+ v.formats.len()
+ );
+ assert!(!heights.is_empty(), "no video in {:?}", v.title);
+ }
+
+ /// #351: what yt-dlp lists on YouTube with no JavaScript runtime (real output, 2026.10.26):
+ /// video-only streams and sound, nothing carrying both. Without ffmpeg only the sound is
+ /// offered, and the window has to say that ffmpeg brings the qualities.
+ #[test]
+ fn only_the_sound_without_ffmpeg_and_a_muxed_format() {
+ let json = r#"{"title": "T", "formats": [
+ {"format_id": "sb0", "ext": "mhtml", "vcodec": "none", "acodec": "none"},
+ {"format_id": "140-0", "ext": "m4a", "vcodec": "none", "acodec": "mp4a.40.2", "filesize": 900},
+ {"format_id": "312", "ext": "mp4", "height": 1080, "vcodec": "avc1.64002A", "acodec": "none", "filesize": 9000},
+ {"format_id": "230", "ext": "mp4", "height": 360, "vcodec": "avc1.4D401E", "acodec": "none", "filesize": 1000}]}"#;
+ let v = parse(json.as_bytes()).unwrap();
+ let without: Vec<String> = choices(&v, false).into_iter().map(|c| c.label).collect();
+ assert_eq!(without, ["Audio only original M4A"]);
+ assert!(needs_merging(&v));
+ let with: Vec<String> = choices(&v, true).into_iter().map(|c| c.label).collect();
+ assert_eq!(&with[..2], ["1080p MP4", "360p MP4"]);
+ // A format carrying both, as good as any video: nothing more to get from merging.
+ let muxed = r#"{"title": "T", "formats": [
+ {"format_id": "18", "ext": "mp4", "height": 360, "vcodec": "avc1", "acodec": "mp4a"},
+ {"format_id": "230", "ext": "mp4", "height": 360, "vcodec": "avc1", "acodec": "none"}]}"#;
+ assert!(!needs_merging(&parse(muxed.as_bytes()).unwrap()));
+ // Sound alone: nothing to merge.
+ let sound = r#"{"title": "T", "formats": [
+ {"format_id": "140", "ext": "m4a", "vcodec": "none", "acodec": "mp4a"}]}"#;
+ assert!(!needs_merging(&parse(sound.as_bytes()).unwrap()));
+ }
+
/// #70: what each audio choice converts to; the original and videos convert nothing.
#[test]
fn audio_conversions() {
diff --git a/crates/tools/src/video.rs b/crates/tools/src/video.rs
index bb74cb7c..c1b10bcd 100644
--- a/crates/tools/src/video.rs
+++ b/crates/tools/src/video.rs
@@ -237,15 +237,16 @@ fn info_file() -> PathBuf {
/// asked for the page (`browser`: its Referer, User-Agent and cookies, `FromBrowser::args`).
/// Without them (#229) a page that wants a sign-in, YouTube's "confirm you're not a bot", was
/// refused here although the video window's look-up, which had them, had listed its qualities.
-fn look_up(exe: &Path, url: &str, browser: &[String]) -> Result<serde_json::Value, String> {
+fn look_up(exe: &Path, url: &str, browser: &[String]) -> Result<(serde_json::Value, bool), String> {
let mut args: Vec<String> = ["-J", "--no-playlist", "--no-warnings"]
.map(String::from)
.to_vec();
args.extend(browser.iter().cloned());
- let cmd = proc::ytdlp(exe, &[], &args, url).map_err(|e| e.to_string())?;
- let out = proc::output(cmd, "yt-dlp", std::time::Duration::from_secs(90))
+ let out = proc::look_up(exe, &args, url, std::time::Duration::from_secs(90))
.map_err(|e| e.to_string())?;
- serde_json::from_slice(&out).map_err(|_| "yt-dlp gave no video information".to_owned())
+ let info = serde_json::from_slice(&out.json)
+ .map_err(|_| "yt-dlp gave no video information".to_owned())?;
+ Ok((info, out.without_cookies))
}
type Child = Arc<Mutex<Option<proc::Spawned>>>;
@@ -638,7 +639,15 @@ fn attempt(
) -> Attempt {
let failed = |error: String, rerouted: bool| Attempt::Failed { error, rerouted };
let mut info = match look_up(exe, url, browser) {
- Ok(v) => v,
+ Ok((v, without_cookies)) => {
+ if without_cookies {
+ note(
+ progress,
+ "The site offered no format with the browser's cookies; looked the page up without them".into(),
+ );
+ }
+ v
+ }
Err(e) => return failed(e, false),
};
let changed = if reroute {
diff --git a/crates/tools/tests/fake_ytdlp.rs b/crates/tools/tests/fake_ytdlp.rs
index 152999cd..f811b0fc 100644
--- a/crates/tools/tests/fake_ytdlp.rs
+++ b/crates/tools/tests/fake_ytdlp.rs
@@ -90,6 +90,17 @@ fn fake_ytdlp() -> ExitCode {
{
return fake_list(list, has("-J"), after("--playlist-items"));
}
+ // #352: yt-dlp's answer when the cookies leave it nothing to offer.
+ if args
+ .last()
+ .is_some_and(|u| u == "https://cookies.example/none")
+ && has("--cookies")
+ {
+ eprintln!(
+ "ERROR: [youtube] abc: Requested format is not available. Use --list-formats for a list of available formats"
+ );
+ return ExitCode::FAILURE;
+ }
if has("-J") {
const PAGE: &str = r#"{"title": "Talk", "language": "ru", "formats": [
{"format_id": "18", "ext": "mp4", "height": 360, "vcodec": "avc1", "acodec": "mp4a"}],
@@ -398,6 +409,27 @@ fn list_checks(me: &Path) {
Looked::Video(_)
));
+ // #352: cookies that leave yt-dlp nothing to offer: the same page without them.
+ let page = "https://cookies.example/none";
+ let cookies = mdm_tools::proc::FromBrowser {
+ cookies: Some("LOGIN_INFO=l; SAPISID=s".into()),
+ ..Default::default()
+ };
+ assert!(matches!(
+ look_up(&exe, page, &cookies).unwrap(),
+ Looked::Video(_)
+ ));
+ let (args, _file) = cookies.args(page).unwrap();
+ let out =
+ mdm_tools::proc::look_up(&exe, &["-J".to_owned()], page, Duration::from_secs(30)).unwrap();
+ assert!(!out.without_cookies, "no cookies, so nothing to retry");
+ let first = ["-J".to_owned()]
+ .into_iter()
+ .chain(args)
+ .collect::<Vec<_>>();
+ let out = mdm_tools::proc::look_up(&exe, &first, page, Duration::from_secs(30)).unwrap();
+ assert!(out.without_cookies, "the second look-up, without them");
+
// Six thousand, whole: all of them, in order, the private ones marked.
let t = Instant::now();
let l = Listing::start(&exe, "https://list.example/playlist/6000", &none, 1, None).unwrap();