extract subscriptions

This commit is contained in:
Paul Campbell 2023-07-25 10:57:19 +01:00
parent a60999785b
commit 13600e0927
2 changed files with 12 additions and 12 deletions

View file

@ -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<std::io::Lines<std::io::BufReader<std::fs::File>>> {
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;

10
src/subscriptions.rs Normal file
View file

@ -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<Lines<BufReader<File>>> {
let file = File::open(file_name)?;
let reader = BufReader::new(file);
Ok(reader.lines())
}