aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.rs
diff options
context:
space:
mode:
authornjaremko2017-07-17 19:58:04 -0400
committernjaremko2017-07-17 19:58:04 -0400
commitc981cf824f5d75423f88437361d915cb1233eb3a (patch)
treebea037bea03603b4333bb1f2ad6a273bb1334eac /src/actions.rs
parent4e128165278d92b5efae7054355037eadbde1724 (diff)
downloadpodcast-c981cf824f5d75423f88437361d915cb1233eb3a.tar.bz2
Fix download support
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/actions.rs b/src/actions.rs
index f126d7f..a228b74 100644
--- a/src/actions.rs
+++ b/src/actions.rs
@@ -27,6 +27,33 @@ pub fn list_subscriptions(state: State) {
}
}
+pub fn download_episode(state: State, p_search: &str, e_search: &str) {
+ let re_pod = Regex::new(&p_search).unwrap();
+ let ep_num = e_search.parse::<usize>().unwrap();
+
+ for subscription in state.subscriptions() {
+ if re_pod.is_match(&subscription.name) {
+ let podcast = Podcast::from_url(&subscription.url).unwrap();
+ let episodes = podcast.episodes();
+ match episodes[episodes.len() - ep_num].download(podcast.title()) {
+ Err(err) => println!("{}", err),
+ _ => (),
+ }
+ }
+ }
+}
+
+pub fn download_all(state: State, p_search: &str) {
+ let re_pod = Regex::new(&p_search).unwrap();
+
+ for subscription in state.subscriptions() {
+ if re_pod.is_match(&subscription.name) {
+ let podcast = Podcast::from_url(&subscription.url).unwrap();
+ podcast.download();
+ }
+ }
+}
+
pub fn stream_episode(state: State, p_search: &str, e_search: &str) {
let re_pod = Regex::new(&p_search).unwrap();
let ep_num = e_search.parse::<usize>().unwrap();