From 8605c20dfc9a802a64b07ac7498794365a79b1a8 Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 21 Sep 2022 22:57:31 +0200 Subject: [PATCH] Rework the potential feed loop so FeedOption is checked. --- source/main.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/source/main.rs b/source/main.rs index 3d7a3bc..c5f0d0c 100644 --- a/source/main.rs +++ b/source/main.rs @@ -81,17 +81,24 @@ fn main() -> Result<()> { .with_style(ProgressStyle::with_template("Verifying {pos}/{len} {bar}")?); for potential_feed in potential_feeds { - let response = ureq_agent.get(&potential_feed.url).call()?; - if response.content_type() == "text/xml" { - let body = response.into_string()?; - let title_start = body.find("").unwrap() + 7; - let title_end = body.find("").unwrap(); - feeds_to_output.push(Feed { - text: Some(body[title_start..title_end].to_string()), - ..potential_feed - }); - } + let potential_feed = if potential_feed.option == FeedOption::AppID { + let response = ureq_agent.get(&potential_feed.url).call()?; + if response.content_type() == "text/xml" { + let body = response.into_string()?; + let title_start = body.find("").unwrap() + 7; + let title_end = body.find("").unwrap(); + Feed { + text: Some(body[title_start..title_end].to_string()), + ..potential_feed + } + } else { + continue; + } + } else { + continue; + }; + feeds_to_output.push(potential_feed); sleep(timeout); progress.inc(1); }