aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs26
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;
}
}
}