Remove FeedOption, this won't be necessary after all.
This commit is contained in:
parent
f49e12db37
commit
e543f0aac0
|
@ -44,9 +44,6 @@ pub struct Args {
|
||||||
/// A simple feed struct.
|
/// A simple feed struct.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Feed {
|
pub struct Feed {
|
||||||
/// The CLI option that was used for this feed.
|
|
||||||
pub option: FeedOption,
|
|
||||||
|
|
||||||
/// The text to use for the feed in the OPML output.
|
/// The text to use for the feed in the OPML output.
|
||||||
pub text: Option<String>,
|
pub text: Option<String>,
|
||||||
|
|
||||||
|
@ -54,16 +51,6 @@ pub struct Feed {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enum for [`Feed`]s for which option was used in the CLI.
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
|
||||||
pub enum FeedOption {
|
|
||||||
/// `-a, --appid <APPID>` was used.
|
|
||||||
AppID,
|
|
||||||
|
|
||||||
/// `--url <URL>` was used.
|
|
||||||
Url,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
install()?;
|
install()?;
|
||||||
|
|
||||||
|
@ -81,7 +68,6 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
for appid in args.appid {
|
for appid in args.appid {
|
||||||
potential_feeds.push(Feed {
|
potential_feeds.push(Feed {
|
||||||
option: FeedOption::AppID,
|
|
||||||
text: Some(format!("Steam AppID {appid}")),
|
text: Some(format!("Steam AppID {appid}")),
|
||||||
url: appid_to_rss_url(appid),
|
url: appid_to_rss_url(appid),
|
||||||
});
|
});
|
||||||
|
@ -94,7 +80,6 @@ fn main() -> Result<()> {
|
||||||
.and_then(|appid_match| appid_match.as_str().parse::<usize>().ok());
|
.and_then(|appid_match| appid_match.as_str().parse::<usize>().ok());
|
||||||
if let Some(appid) = appid {
|
if let Some(appid) = appid {
|
||||||
potential_feeds.push(Feed {
|
potential_feeds.push(Feed {
|
||||||
option: FeedOption::Url,
|
|
||||||
text: Some(format!("Steam AppID {appid}")),
|
text: Some(format!("Steam AppID {appid}")),
|
||||||
url: appid_to_rss_url(appid),
|
url: appid_to_rss_url(appid),
|
||||||
});
|
});
|
||||||
|
@ -106,21 +91,15 @@ fn main() -> Result<()> {
|
||||||
.with_style(ProgressStyle::with_template("Verifying {pos}/{len} {bar}")?);
|
.with_style(ProgressStyle::with_template("Verifying {pos}/{len} {bar}")?);
|
||||||
|
|
||||||
for potential_feed in potential_feeds {
|
for potential_feed in potential_feeds {
|
||||||
let potential_feed = if [FeedOption::AppID, FeedOption::Url]
|
let response = ureq_agent.get(&potential_feed.url).call()?;
|
||||||
.contains(&potential_feed.option)
|
sleep(timeout);
|
||||||
{
|
let potential_feed = if response.content_type() == "text/xml" {
|
||||||
let response = ureq_agent.get(&potential_feed.url).call()?;
|
let body = response.into_string()?;
|
||||||
sleep(timeout);
|
let title_start = body.find("<title>").unwrap() + 7;
|
||||||
if response.content_type() == "text/xml" {
|
let title_end = body.find("</title>").unwrap();
|
||||||
let body = response.into_string()?;
|
Feed {
|
||||||
let title_start = body.find("<title>").unwrap() + 7;
|
text: Some(body[title_start..title_end].to_string()),
|
||||||
let title_end = body.find("</title>").unwrap();
|
..potential_feed
|
||||||
Feed {
|
|
||||||
text: Some(body[title_start..title_end].to_string()),
|
|
||||||
..potential_feed
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue