Skip to content

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

Download video: a sound-only choice saves in Music (#611) (#614)

Ahmed Nefzaoui7dc0e3a9567b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8866048..2d77d0e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- **Download video**: a sound-only choice (MP3, Opus, FLAC, the original sound) saves in the Music category's folder and is listed under Music, as a playlist downloaded as sound only does; choosing a video again goes back to the Video folder. A folder you typed or picked in **Save to** stays as it is ([#611](https://github.com/anefzaoui/misterdownloadmanager/issues/611)).
- **Options → Save to**: changing the **General** category's default download directory now moves the default folders of all other categories without their own folder (`Video`, `Music`, `Torrents`, etc.) under it, instead of leaving them under the system's `Downloads` folder ([#556](https://github.com/anefzaoui/misterdownloadmanager/issues/556)). **Add torrent** also starts with the **Torrents** category's folder from the moment it opens (so **Save to** no longer flips when a magnet link's metadata arrives) and remembers a changed folder when **Change folder for this category on last selected** is ticked ([#550](https://github.com/anefzaoui/misterdownloadmanager/issues/550)).
- Windows: dragging a finished file out of **Download complete** (the grip at its bottom right) no longer holds up MDM's windows for as long as the drag lasts, or for as long as the program it is dropped on takes to answer: the drag now runs beside the window, as file dialogs already do ([#561](https://github.com/anefzaoui/misterdownloadmanager/issues/561)).
- Menus: going from an item with a submenu to another item closes the submenu at once, and only the item under the pointer is lit. The submenu stayed open, its item lit as well, until the pointer rested on one item, so as long as it kept moving; going diagonally into the submenu still keeps it open ([#579](https://github.com/anefzaoui/misterdownloadmanager/issues/579)).
diff --git a/ROADMAP.md b/ROADMAP.md
index 427f1b8c..cc9d6f52 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -514,6 +514,9 @@ These ship in a later version, when they're ready.
### Being built
+- 🔄 Download video: a sound-only choice (MP3, a playlist as sound) saved in the Music folder and
+ listed under Music ([#611](https://github.com/anefzaoui/misterdownloadmanager/issues/611)):
+ in review
- 🔄 Linux and macOS: the system's gallery-dl used when MDM has none of its own, as yt-dlp is
([#571](https://github.com/anefzaoui/misterdownloadmanager/issues/571)): in review
- 🔄 Videos sent in pieces (HLS, DASH) downloading several pieces at once, as many as a file's
diff --git a/crates/app/src/app.rs b/crates/app/src/app.rs
index d19280fa..487ad286 100644
--- a/crates/app/src/app.rs
+++ b/crates/app/src/app.rs
@@ -2353,13 +2353,8 @@ impl App {
// dialog opens, as its window is its own.
if let Some(page) = cmd.video_page.as_deref() {
self.show_for_dialog(ctx);
- let dir = self.settings.category_dir(Category::Video, &self.downloads);
- crate::videodlg::refresh_ytdlp(&self.rt);
let page = page.to_owned();
- self.video_dlg = Some(
- crate::videodlg::VideoDialog::for_page(dir, &page, cmd)
- .with_subs(self.settings.video_subs.clone()),
- );
+ self.video_dlg = Some(self.video_dialog(Some((&page, cmd))));
return;
}
// Its menu: never on this site.
@@ -3453,6 +3448,22 @@ impl App {
}
}
+ /// Download video from a page, opened for a page (looked up at once) or from the menu: Save
+ /// to is the Video category's folder, the Music category's while a sound-only choice is
+ /// chosen (#611; not when the user deleted Music).
+ fn video_dialog(&self, page: Option<(&str, mdm_ipc::Command)>) -> crate::videodlg::VideoDialog {
+ crate::videodlg::refresh_ytdlp(&self.rt);
+ let dir = self.settings.category_dir(Category::Video, &self.downloads);
+ let music = (!Category::Music.deleted())
+ .then(|| self.settings.category_dir(Category::Music, &self.downloads));
+ match page {
+ Some((page, cmd)) => crate::videodlg::VideoDialog::for_page(dir, page, cmd),
+ None => crate::videodlg::VideoDialog::new(dir),
+ }
+ .with_subs(self.settings.video_subs.clone())
+ .with_music_folder(music)
+ }
+
/// Download video from a page → Download Now / Later.
fn add_video(&mut self, add: crate::videodlg::VideoAdd) {
let folder = add
@@ -3479,7 +3490,7 @@ impl App {
let id = self.push_item(
add.page,
dest,
- Category::Video,
+ add.category,
String::new(),
add.size,
None,
@@ -3527,7 +3538,7 @@ impl App {
let id = self.push_item(
page,
dest,
- Category::Video,
+ add.category,
String::new(),
None,
None,
@@ -5363,12 +5374,7 @@ impl App {
},
Cmd::VideoPage => {
if self.video_dlg.is_none() {
- let dir = self.settings.category_dir(Category::Video, &self.downloads);
- crate::videodlg::refresh_ytdlp(&self.rt);
- self.video_dlg = Some(
- crate::videodlg::VideoDialog::new(dir)
- .with_subs(self.settings.video_subs.clone()),
- );
+ self.video_dlg = Some(self.video_dialog(None));
}
}
Cmd::AddMagnet => self.open_torrent_dialog(None, ctx),
@@ -8250,16 +8256,8 @@ impl App {
// A video's page, not a file (YouTube, Vimeo…): the video window looks it up.
Outcome::Done(new) if mdm_tools::pages::is_video_page(&new.url) => {
self.add_url = None;
- let dir = self.settings.category_dir(Category::Video, &self.downloads);
- crate::videodlg::refresh_ytdlp(&self.rt);
- self.video_dlg = Some(
- crate::videodlg::VideoDialog::for_page(
- dir,
- new.url.as_str(),
- Default::default(),
- )
- .with_subs(self.settings.video_subs.clone()),
- );
+ self.video_dlg =
+ Some(self.video_dialog(Some((new.url.as_str(), Default::default()))));
}
// An image gallery's page (Wikimedia Commons, Flickr…): gallery-dl (#58).
Outcome::Done(new) if mdm_tools::pages::is_gallery_page(&new.url) => {
@@ -8579,10 +8577,11 @@ impl App {
Outcome::Closed => self.video_dlg = None,
Outcome::Done(out) => {
// Options' "Change folder for this category on last selected", which
- // Download File Info follows through its box (#475).
+ // Download File Info follows through its box (#475): Music's for a
+ // sound-only choice (#611).
if self.settings.change_folder_on_last
&& self.settings.keep_category_dir(
- Category::Video,
+ v.category(),
&v.save_folder(),
&self.downloads,
)
diff --git a/crates/app/src/playlistdlg.rs b/crates/app/src/playlistdlg.rs
index 849245b3..3d32664c 100644
--- a/crates/app/src/playlistdlg.rs
+++ b/crates/app/src/playlistdlg.rs
@@ -29,6 +29,8 @@ pub struct PlaylistAdd {
pub ext: &'static str,
/// Where they go: Save to, then a folder named after the list.
pub folder: PathBuf,
+ /// The category each is listed under: Music for a sound-only quality (#611), else Video.
+ pub category: crate::model::Category,
pub start_now: bool,
/// What the browser's request for the page carried, for each look-up.
pub context: mdm_ipc::Command,
@@ -41,6 +43,12 @@ struct Pick {
ext: &'static str,
}
+impl Pick {
+ fn sound_only(&self) -> bool {
+ mdm_tools::resolve::sound_only(&self.selector, self.ext)
+ }
+}
+
/// The heights offered, as "Up to …p": each video at that height, or the best below it.
const HEIGHTS: [u32; 6] = [2160, 1440, 1080, 720, 480, 360];
/// The one chosen at first: Up to 1080p.
@@ -127,6 +135,8 @@ pub struct PlaylistView {
pick: usize,
/// The file type the chosen quality gives (each row shows its icon).
ext: &'static str,
+ /// The chosen quality saves only the sound (#611: Save to is then the Music category's).
+ sound: bool,
error: Option<String>,
confirm: Option<(Confirm, bool)>,
}
@@ -155,6 +165,7 @@ impl PlaylistView {
rows: Default::default(),
pick: DEFAULT_PICK,
ext: "mp4",
+ sound: false,
error: None,
confirm: None,
};
@@ -210,6 +221,7 @@ impl PlaylistView {
rows: Default::default(),
pick,
ext: picks[pick].ext,
+ sound: picks[pick].sound_only(),
error: None,
confirm: None,
}
@@ -287,6 +299,11 @@ impl PlaylistView {
self.chosen
}
+ /// The quality chosen saves only the sound.
+ pub fn sound_only(&self) -> bool {
+ self.sound
+ }
+
/// Fewer listed than the site says the list has.
fn short(&self) -> bool {
self.total.is_some_and(|t| (self.entries.len() as u64) < t)
@@ -586,6 +603,7 @@ impl PlaylistView {
}
if let Some(p) = picks.get(self.pick.min(picks.len().saturating_sub(1))) {
self.ext = p.ext;
+ self.sound = p.sound_only();
}
}
@@ -626,13 +644,15 @@ impl PlaylistView {
}
}
- /// What Download adds: the ticked videos, the quality chosen, into Save to/<list title>.
+ /// What Download adds: the ticked videos, the quality chosen, into Save to/<list title>,
+ /// listed under `category`.
pub fn add(
&self,
folder: &Path,
merge: bool,
start_now: bool,
context: &mdm_ipc::Command,
+ category: crate::model::Category,
) -> PlaylistAdd {
let picks = picks(merge);
let pick = &picks[self.pick.min(picks.len() - 1)];
@@ -648,6 +668,7 @@ impl PlaylistView {
selector: pick.selector.clone(),
ext: pick.ext,
folder: folder.join(mdm_engine::naming::sanitize(&self.title)),
+ category,
start_now,
context: context.clone(),
}
@@ -684,5 +705,10 @@ mod tests {
assert_eq!(plain[DEFAULT_PICK].selector, "b[height<=1080]");
assert!(!plain.iter().any(|p| p.selector.starts_with("mp3:")));
assert!(!plain.iter().any(|p| p.ext == "opus" || p.ext == "flac"));
+ // #611: the "Audio only" ones save only the sound, the heights don't.
+ for p in m.iter().chain(&plain) {
+ let audio = p.selector == "ba" || p.ext != "mp4";
+ assert_eq!(p.sound_only(), audio, "{}", p.selector);
+ }
}
}
diff --git a/crates/app/src/videodlg.rs b/crates/app/src/videodlg.rs
index ce3d72ef..59d77f6c 100644
--- a/crates/app/src/videodlg.rs
+++ b/crates/app/src/videodlg.rs
@@ -11,6 +11,7 @@ use mdm_tools::resolve::{Choice, Looked, SubChoice, Video};
use mdm_tools::video::{ALL_UPLOADERS, Subs};
use crate::dialogs::{Outcome, window};
+use crate::model::Category;
use crate::winui::{self, ButtonKind, r, text};
type Slot<T> = Arc<Mutex<Option<Result<T, String>>>>;
@@ -26,6 +27,8 @@ pub struct VideoAdd {
pub page: url::Url,
pub selector: String,
pub dest: PathBuf,
+ /// The category it is listed under: Music for a sound-only choice (#611), else Video.
+ pub category: Category,
pub size: Option<u64>,
pub start_now: bool,
/// What the browser's request for the page carried (its button), for yt-dlp to ask the
@@ -50,7 +53,15 @@ pub struct VideoDialog {
/// The browser's request context for `page` as it came (VideoAdd::context).
context: mdm_ipc::Command,
from_browser: String,
+ /// Save to.
folder: String,
+ /// The Video and Music categories' folders MDM puts in Save to (#611): Music's while a
+ /// sound-only choice is chosen, as long as Save to holds one of them (a folder typed or
+ /// picked stays). No Music folder: the Music category was deleted, all goes as video.
+ video_dir: String,
+ music_dir: Option<String>,
+ /// Save to was last set for a sound-only choice.
+ sound: bool,
name: String,
lookup: Option<Slot<Looked>>,
/// The yt-dlp and the browser's context the look-up ran with (a list is listed with them).
@@ -125,6 +136,7 @@ fn tools() -> Tools {
}
impl VideoDialog {
+ /// Opened from the menu: a video page's address on the clipboard is taken.
pub fn new(folder: PathBuf) -> Self {
let page = crate::clipboard_text()
.map(|t| t.trim().to_owned())
@@ -132,9 +144,21 @@ impl VideoDialog {
.unwrap_or_default();
VideoDialog {
page,
+ ..Self::blank(folder)
+ }
+ }
+
+ /// No address yet, saving into `folder` (the Video category's).
+ fn blank(folder: PathBuf) -> Self {
+ let folder = folder.display().to_string();
+ VideoDialog {
+ page: String::new(),
context: Default::default(),
from_browser: String::new(),
- folder: folder.display().to_string(),
+ video_dir: folder.clone(),
+ music_dir: None,
+ sound: false,
+ folder,
name: String::new(),
lookup: None,
looking: None,
@@ -166,6 +190,13 @@ impl VideoDialog {
self
}
+ /// Save to switches to `dir`, the Music category's folder, while a sound-only choice is
+ /// chosen (#611); None (the Music category was deleted): sound goes as video does.
+ pub fn with_music_folder(mut self, dir: Option<PathBuf>) -> Self {
+ self.music_dir = dir.map(|d| d.display().to_string());
+ self
+ }
+
/// Opened for `page` (Add URL was given a video's page, or the browser's button was
/// clicked with `context`): looks it up at once.
pub fn for_page(folder: PathBuf, page: &str, mut context: mdm_ipc::Command) -> Self {
@@ -181,7 +212,7 @@ impl VideoDialog {
from_browser: page,
context,
auto_look: true,
- ..Self::new(folder)
+ ..Self::blank(folder)
}
}
@@ -390,6 +421,8 @@ impl VideoDialog {
winui::BG(),
|ui, o| self.body(ui, o, rt),
);
+ // A playlist's quality chosen, a list or a video looked up: Save to follows (#611).
+ self.follow_sound();
// Helpers... open: on Close, the helpers are read again (another program, or MDM's own).
if let Some(h) = &mut self.helpers
&& !matches!(h.show(ctx, rt), Outcome::Open)
@@ -402,49 +435,97 @@ impl VideoDialog {
}
let folder = crate::dialogs::resolve_path(&self.folder);
let out = crate::dialogs::ensure_folder(ctx, &mut self.asking, out, &folder);
- // A playlist's videos, each its own download.
- if let (Some(list), Outcome::Done(())) = (&self.list, &out) {
+ match out {
+ Outcome::Open => Outcome::Open,
+ Outcome::Closed => Outcome::Closed,
+ Outcome::Done(()) => self.added().map_or(Outcome::Closed, Outcome::Done),
+ }
+ }
+
+ /// What Download Now or Later adds: a playlist's videos, each its own download, or the
+ /// video looked up (none when there is nothing to add).
+ fn added(&self) -> Option<VideoOut> {
+ let folder = self.save_folder();
+ let start_now = self.start_now.unwrap_or(true);
+ if let Some(list) = &self.list {
let merge = self.tools.as_ref().is_some_and(|t| t.2.is_some());
- let start_now = self.start_now.unwrap_or(true);
- return Outcome::Done(VideoOut::Many(list.add(
+ return Some(VideoOut::Many(list.add(
&folder,
merge,
start_now,
&self.context(),
+ self.category(),
)));
}
- match out {
- Outcome::Open => Outcome::Open,
- Outcome::Closed => Outcome::Closed,
- Outcome::Done(()) => {
- let (Some((_, choices)), Ok(page)) =
- (&self.video, url::Url::parse(self.page.trim()))
- else {
- return Outcome::Closed;
- };
- let c = &choices[self.chosen.min(choices.len() - 1)];
- let name = mdm_engine::naming::sanitize(self.name.trim());
- let chosen = self.chosen_subs();
- Outcome::Done(VideoOut::One(VideoAdd {
- page,
- selector: c.selector.clone(),
- dest: crate::dialogs::resolve_path(&self.folder).join(name),
- size: c.size,
- start_now: self.start_now.unwrap_or(true),
- context: self.context(),
- // Into the video only where its file type holds them (and with ffmpeg,
- // which VideoJob checks).
- subs: if mdm_tools::resolve::is_audio(c) {
- Subs::default()
- } else {
- Subs {
- embed: chosen.embed && mdm_tools::resolve::holds_subtitles(c),
- ..chosen.clone()
- }
- },
- remember: (!self.subs.is_empty()).then_some(chosen),
- }))
- }
+ let (Some((_, choices)), Ok(page)) = (&self.video, url::Url::parse(self.page.trim()))
+ else {
+ return None;
+ };
+ let c = choices.get(self.chosen.min(choices.len().checked_sub(1)?))?;
+ let name = mdm_engine::naming::sanitize(self.name.trim());
+ let chosen = self.chosen_subs();
+ Some(VideoOut::One(VideoAdd {
+ page,
+ selector: c.selector.clone(),
+ dest: folder.join(name),
+ category: self.category(),
+ size: c.size,
+ start_now,
+ context: self.context(),
+ // Into the video only where its file type holds them (and with ffmpeg, which
+ // VideoJob checks).
+ subs: if mdm_tools::resolve::is_audio(c) {
+ Subs::default()
+ } else {
+ Subs {
+ embed: chosen.embed && mdm_tools::resolve::holds_subtitles(c),
+ ..chosen.clone()
+ }
+ },
+ remember: (!self.subs.is_empty()).then_some(chosen),
+ }))
+ }
+
+ /// The choice (or the playlist's quality) saves only the sound; None while there is none.
+ fn sound_only(&self) -> Option<bool> {
+ if let Some(list) = &self.list {
+ return Some(list.sound_only());
+ }
+ let (_, choices) = self.video.as_ref()?;
+ choices.get(self.chosen).map(mdm_tools::resolve::is_audio)
+ }
+
+ /// The category the download is listed under (#611), and whose folder "Change folder for
+ /// this category on last selected" keeps: Music for a sound-only choice, else Video.
+ pub fn category(&self) -> Category {
+ if self.music_dir.is_some() && self.sound_only() == Some(true) {
+ Category::Music
+ } else {
+ Category::Video
+ }
+ }
+
+ /// Save to goes to the Music category's folder when the choice turns sound-only, back to
+ /// Video's when it turns video again, but only while it holds the folder MDM put there: a
+ /// folder the user typed or picked is theirs (#611).
+ fn follow_sound(&mut self) {
+ let Some(sound) = self.sound_only() else {
+ return;
+ };
+ if sound == self.sound {
+ return;
+ }
+ self.sound = sound;
+ let Some(music) = &self.music_dir else {
+ return;
+ };
+ let (from, to) = if sound {
+ (&self.video_dir, music)
+ } else {
+ (music, &self.video_dir)
+ };
+ if crate::dialogs::resolve_path(&self.folder) == crate::dialogs::resolve_path(from) {
+ self.folder = to.clone();
}
}
@@ -453,6 +534,7 @@ impl VideoDialog {
crate::dialogs::resolve_path(&self.folder)
}
+ /// The file name, and Save to (#611), follow the choice.
fn name_from_choice(&mut self) {
if let Some((v, choices)) = &self.video
&& let Some(c) = choices.get(self.chosen)
@@ -460,6 +542,7 @@ impl VideoDialog {
let stem = mdm_engine::naming::sanitize(&v.title);
self.name = format!("{stem}.{}", c.ext);
}
+ self.follow_sound();
}
/// Install a helper in the background.
@@ -1425,7 +1508,7 @@ mod tests {
/// Each entry stands for what yt-dlp is asked.
#[test]
fn entries_ask_for_their_subtitles() {
- let mut d = VideoDialog::new(PathBuf::from("."));
+ let mut d = VideoDialog::blank(PathBuf::from("."));
d.subs = vec![sub("de", false), sub("fr", false), sub("en-orig", true)];
d.embed = true;
let mut at = |i: usize| {
@@ -1439,4 +1522,122 @@ mod tests {
assert_eq!(auto.langs, ["en-orig"]);
assert!(auto.automatic && auto.embed);
}
+
+ /// The Video and Music categories' folders (not made: only their names are compared).
+ fn dirs() -> (PathBuf, PathBuf) {
+ let base = std::env::temp_dir().join("mdm-611");
+ (base.join("Video"), base.join("Music"))
+ }
+
+ /// Download video as the app opens it (Save to: Video's folder, Music's offered), a video
+ /// with a sound-only choice and video ones looked up, without yt-dlp or ffmpeg.
+ fn looked_up(music: bool) -> VideoDialog {
+ const SAMPLE: &str = r#"{"title": "A talk", "duration": 60, "formats": [
+ {"format_id": "140", "ext": "m4a", "vcodec": "none", "acodec": "mp4a", "filesize": 2900},
+ {"format_id": "18", "ext": "mp4", "height": 360, "vcodec": "avc1", "acodec": "mp4a", "filesize": 6100}]}"#;
+ let (video, music_dir) = dirs();
+ let mut d = VideoDialog::for_page(video, "https://video.example/talk", Default::default())
+ .with_music_folder(music.then_some(music_dir));
+ // No helpers looked for on this computer: no merged qualities.
+ d.tools = Some((None, None, None));
+ d.looked_up = d.page.clone();
+ d.set_video(mdm_tools::resolve::parse(SAMPLE.as_bytes()).unwrap());
+ d
+ }
+
+ /// The choices' rows: (a sound-only one, a video one).
+ fn rows(d: &VideoDialog) -> (usize, usize) {
+ let choices = &d.video.as_ref().unwrap().1;
+ let sound = choices.iter().position(mdm_tools::resolve::is_audio);
+ let video = choices
+ .iter()
+ .position(|c| !mdm_tools::resolve::is_audio(c));
+ (sound.unwrap(), video.unwrap())
+ }
+
+ /// A row clicked in the choices list, as the list does it.
+ fn choose(d: &mut VideoDialog, row: usize) {
+ d.chosen = row;
+ d.name_from_choice();
+ }
+
+ /// What Download Now adds for a single video: (its folder, its category).
+ fn one(d: &VideoDialog) -> (PathBuf, Category) {
+ match d.added() {
+ Some(VideoOut::One(add)) => (add.dest.parent().unwrap().to_owned(), add.category),
+ _ => panic!("a video is added"),
+ }
+ }
+
+ /// #611: a sound-only choice saves in the Music category's folder and is listed under Music;
+ /// a video choice again goes back to Video's.
+ #[test]
+ fn a_sound_only_choice_saves_in_music_and_back() {
+ let (video, music) = dirs();
+ let mut d = looked_up(true);
+ let (sound, film) = rows(&d);
+ choose(&mut d, film);
+ assert_eq!(d.save_folder(), video);
+ assert_eq!(one(&d), (video.clone(), Category::Video));
+ choose(&mut d, sound);
+ assert_eq!(
+ d.save_folder(),
+ music,
+ "Save to follows a sound-only choice"
+ );
+ assert_eq!(one(&d), (music.clone(), Category::Music));
+ assert_eq!(d.category(), Category::Music, "the folder kept is Music's");
+ choose(&mut d, film);
+ assert_eq!(d.save_folder(), video, "and goes back for a video");
+ assert_eq!(one(&d), (video, Category::Video));
+ }
+
+ /// #611: a folder the user typed or picked stays whatever is chosen; a sound-only download
+ /// into it is still listed under Music.
+ #[test]
+ fn a_folder_the_user_chose_stays() {
+ let mut d = looked_up(true);
+ let (sound, film) = rows(&d);
+ let own = std::env::temp_dir().join("mdm-611").join("Talks");
+ d.folder = own.display().to_string();
+ choose(&mut d, sound);
+ assert_eq!(d.save_folder(), own);
+ assert_eq!(one(&d), (own.clone(), Category::Music));
+ choose(&mut d, film);
+ assert_eq!(d.save_folder(), own);
+ assert_eq!(one(&d), (own, Category::Video));
+ }
+
+ /// The Music category deleted (#93): sound-only goes where video does, as before.
+ #[test]
+ fn without_a_music_category_sound_goes_as_video() {
+ let (video, _) = dirs();
+ let mut d = looked_up(false);
+ let (sound, _) = rows(&d);
+ choose(&mut d, sound);
+ assert_eq!(d.save_folder(), video);
+ assert_eq!(one(&d), (video, Category::Video));
+ }
+
+ /// #611: a playlist downloaded as sound only goes into the Music category's folder (then the
+ /// list's own folder) and each of its videos is listed under Music; a video quality, Video's.
+ #[test]
+ fn a_playlist_as_sound_saves_in_music() {
+ let (video, music) = dirs();
+ let many = |d: &VideoDialog| match d.added() {
+ Some(VideoOut::Many(add)) => (add.folder.parent().unwrap().to_owned(), add.category),
+ _ => panic!("a playlist is added"),
+ };
+ // "Audio only, original" (7), then "Up to 1080p" (3).
+ for (pick, folder, category) in
+ [("7", music, Category::Music), ("3", video, Category::Video)]
+ {
+ let mut d = looked_up(true);
+ d.show_sample_list(pick);
+ // As each frame of the window does.
+ d.follow_sound();
+ assert_eq!(d.save_folder(), folder, "quality {pick}");
+ assert_eq!(many(&d), (folder, category), "quality {pick}");
+ }
+ }
}
diff --git a/crates/tools/src/resolve.rs b/crates/tools/src/resolve.rs
index abbe6341..3f83ec65 100644
--- a/crates/tools/src/resolve.rs
+++ b/crates/tools/src/resolve.rs
@@ -373,7 +373,13 @@ fn audio_container(ext: &str) -> bool {
/// A choice that saves only the sound (no picture to show subtitles on, #68).
pub fn is_audio(c: &Choice) -> bool {
- c.selector == "ba" || audio_conversion(&c.selector).is_some() || audio_container(&c.ext)
+ sound_only(&c.selector, &c.ext)
+}
+
+/// A selector and file type that save only the sound: a choice ([`is_audio`]) or a playlist's
+/// quality (saved in the Music category's folder, #611).
+pub fn sound_only(selector: &str, ext: &str) -> bool {
+ selector == "ba" || audio_conversion(selector).is_some() || audio_container(ext)
}
/// A choice whose file can hold subtitles put into it (yt-dlp's `--embed-subs` with SRT).