diff --git a/src/lib.rs b/src/lib.rs index c98b471..e698fa7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,17 @@ // https://www.phind.com/agent?cache=clke9xk39001cmj085upzho1t -use std::fs::File; - use atom_syndication::Link; mod errors; mod feed; mod history; pub mod prelude; +mod subscriptions; use prelude::*; pub fn run(subscriptions: &str, history: &str, site: &str) -> Result<()> { - for channel_name in lines_from(subscriptions)? { + for channel_name in subscriptions::lines_from(subscriptions)? { let channel_name = channel_name?; println!("Channel: {}", channel_name); let feed_url = feed::get_feed_url(site, &channel_name)?; @@ -29,15 +28,6 @@ pub fn run(subscriptions: &str, history: &str, site: &str) -> Result<()> { Ok(()) } -// read list of rss feed URLs from file 'feeds.txt' -fn lines_from(file_name: &str) -> Result>> { - use std::io::{BufRead, BufReader}; - - let file = File::open(file_name)?; - let reader = BufReader::new(file); - Ok(reader.lines()) -} - fn download_audio(link: &Link) -> Result<()> { use std::process::Command; diff --git a/src/subscriptions.rs b/src/subscriptions.rs new file mode 100644 index 0000000..a9f7cde --- /dev/null +++ b/src/subscriptions.rs @@ -0,0 +1,10 @@ +use crate::prelude::*; + +use std::fs::File; +use std::io::{BufRead, BufReader, Lines}; + +pub fn lines_from(file_name: &str) -> Result>> { + let file = File::open(file_name)?; + let reader = BufReader::new(file); + Ok(reader.lines()) +}