diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/actions.rs | 1 | ||||
| -rw-r--r-- | src/main.rs | 4 | ||||
| -rw-r--r-- | src/structs.rs | 35 |
3 files changed, 28 insertions, 12 deletions
diff --git a/src/actions.rs b/src/actions.rs index 93ddf07..3d89002 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -291,7 +291,6 @@ fn launch_vlc(url: &str) { } } - pub fn remove_podcast(state: &mut State, p_search: &str) { if p_search == "*" { match Podcast::delete_all() { diff --git a/src/main.rs b/src/main.rs index 61d4258..e7f4e75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use structs::*; use clap::{App, Arg, SubCommand}; -const VERSION: &str = "0.4.7"; +const VERSION: &str = "0.5.0"; fn main() { if let Err(err) = create_directories() { @@ -178,4 +178,4 @@ fn main() { if let Err(err) = state.save() { eprintln!("{}", err); } -}
\ No newline at end of file +} diff --git a/src/structs.rs b/src/structs.rs index b6a1d38..b9db14d 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -41,7 +41,6 @@ impl Config { } } - #[derive(Serialize, Deserialize, Clone)] pub struct Subscription { pub title: String, @@ -216,20 +215,39 @@ impl Podcast { } pub fn download(&self) -> Result<(), io::Error> { + print!("You are about to download all episodes (y/n): "); + io::stdout().flush().ok(); + let mut input = String::new(); + if let Ok(_) = io::stdin().read_line(&mut input) { + if input.to_lowercase().trim() != "y" { + return Ok(()); + } + } + let mut path = get_podcast_dir(); path.push(self.title()); - let downloaded = already_downloaded(self.title())?; - - self.episodes().par_iter().for_each(|ref i| { - if let Some(ep_title) = i.title() { - if !downloaded.contains(ep_title) { + match already_downloaded(self.title()) { + Ok(downloaded) => { + self.episodes().par_iter().for_each(|ref i| { + if let Some(ep_title) = i.title() { + if !downloaded.contains(ep_title) { + if let Err(err) = i.download(self.title()) { + println!("{}", err); + } + } + } + }); + } + Err(_) => { + self.episodes().par_iter().for_each(|ref i| { if let Err(err) = i.download(self.title()) { println!("{}", err); } - } + }); } - }); + } + Ok(()) } @@ -277,7 +295,6 @@ impl Episode { } } - pub fn download(&self, podcast_name: &str) -> Result<(), io::Error> { let mut path = get_podcast_dir(); path.push(podcast_name); |
