From 2c953b5997e2a0f86b98c9ef27922acdfe4a77c7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 24 Jul 2023 07:40:20 +0100 Subject: [PATCH] extract site as a parameter --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index fbb1747..566c64b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,10 +55,11 @@ fn main() -> Result<()> { println!("Podal"); let subscriptions = "subscriptions.txt"; let history = "downloaded.txt"; + let site = "https://www.youtube.com/"; for channel_name in lines_from(subscriptions)? { let channel_name = channel_name?; - let feed_url = get_feed_url(channel_name)?; + let feed_url = get_feed_url(site, channel_name)?; for entry in get_feed(feed_url)?.entries() { if let Some(link) = get_link(entry) { if !is_already_downloaded(&link, history)? { @@ -73,13 +74,13 @@ fn main() -> Result<()> { Ok(()) } -fn get_feed_url(channel_name: String) -> Result { +fn get_feed_url(site: &str, channel_name: String) -> Result { if let Some(channel_prefix) = channel_name.chars().next() { if channel_prefix != '@' { return Err(format!("Channel Name must begin with an '@': {}", channel_name).into()); } } - let channel_url = format!("https://www.youtube.com/{}", channel_name); + let channel_url = format!("{}{}", site, channel_name); let response = reqwest::blocking::get(channel_url)?; let rss_url = scraper::Html::parse_document(&response.text()?) .select(&scraper::Selector::parse("link[title='RSS']").unwrap())