38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
mod errors;
|
|
pub mod feed;
|
|
pub mod fetch;
|
|
pub mod history;
|
|
pub mod prelude;
|
|
mod subscriptions;
|
|
|
|
use feed::{FeedFind, FeedGet};
|
|
use fetch::FetchDownload;
|
|
use history::{HistoryAdd, HistoryFind};
|
|
use prelude::*;
|
|
|
|
pub fn run(
|
|
subscriptions: &str,
|
|
history: &str,
|
|
site: &str,
|
|
feed_find: FeedFind,
|
|
feed_get: FeedGet,
|
|
history_find: HistoryFind,
|
|
history_add: HistoryAdd,
|
|
fetch_download: FetchDownload,
|
|
) -> Result<()> {
|
|
for channel_name in subscriptions::lines_from(subscriptions)? {
|
|
let channel_name = channel_name?;
|
|
println!("Channel: {}", channel_name);
|
|
let feed_url = feed_find(site, &channel_name)?;
|
|
for entry in feed_get(&feed_url)?.entries() {
|
|
if let Some(link) = entry.links().get(0).cloned() {
|
|
if !history_find(&link, history)? {
|
|
println!("Downloading {}: {}", &channel_name, entry.title().as_str());
|
|
fetch_download(&link)?;
|
|
history_add(&link, history)?;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|