diff options
| author | Nathan Jaremko | 2017-07-26 16:47:13 -0400 |
|---|---|---|
| committer | Nathan Jaremko | 2017-07-26 16:47:13 -0400 |
| commit | 4ff4a4e802595f2fac1175c6cb62bb49c6ffda64 (patch) | |
| tree | bd5f826e1f01c99c474c6e48ac667780e5e42f3d /src/actions.rs | |
| parent | cd7b8cb559199c609331b5851076f5a0ed9e1d54 (diff) | |
| download | podcast-4ff4a4e802595f2fac1175c6cb62bb49c6ffda64.tar.bz2 | |
Transfer all work from chromebook
Diffstat (limited to 'src/actions.rs')
| -rw-r--r-- | src/actions.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/actions.rs b/src/actions.rs index 5c67c40..553ac37 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -9,20 +9,22 @@ use std::process::Command; use structs::*; use utils::*; -pub fn list_episodes(state: &State, search: &str) { +pub fn list_episodes(search: &str) { let re = Regex::new(search).unwrap(); - for podcast in &state.subs { - if re.is_match(&podcast.title) { - println!("Episodes for {}:", &podcast.title); - match Podcast::from_url(&podcast.url) { - Ok(podcast) => { - let episodes = podcast.episodes(); - for (index, episode) in episodes.iter().enumerate() { - println!("({}) {}", episodes.len() - index, episode.title().unwrap()); - } - } - Err(err) => println!("{}", err), + let mut path = get_podcast_dir(); + path.push(".rss"); + DirBuilder::new().recursive(true).create(&path).unwrap(); + for entry in fs::read_dir(&path).unwrap() { + let entry = entry.unwrap(); + if re.is_match(&entry.file_name().into_string().unwrap()) { + let file = File::open(&entry.path()).unwrap(); + let channel = Channel::read_from(BufReader::new(file)).unwrap(); + let podcast = Podcast::from(channel); + let episodes = podcast.episodes(); + for (num, ep) in episodes.iter().enumerate() { + println!("({}) {}", episodes.len()-num, ep.title().unwrap()); } + return; } } } |
