Compare commits
3 Commits
f27795fcfe
...
f52d89ad24
Author | SHA1 | Date |
---|---|---|
Bauke | f52d89ad24 | |
Bauke | 51e048ec40 | |
Bauke | b443104375 |
|
@ -36,6 +36,16 @@ pub struct Args {
|
||||||
pub verify: bool,
|
pub verify: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A simple feed struct.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Feed {
|
||||||
|
/// The text to use for the feed in the OPML output.
|
||||||
|
pub text: Option<String>,
|
||||||
|
|
||||||
|
/// The URL of the feed.
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
install()?;
|
install()?;
|
||||||
|
|
||||||
|
@ -49,8 +59,10 @@ fn main() -> Result<()> {
|
||||||
let mut feeds_to_output = vec![];
|
let mut feeds_to_output = vec![];
|
||||||
|
|
||||||
for appid in args.appid {
|
for appid in args.appid {
|
||||||
potential_feeds
|
potential_feeds.push(Feed {
|
||||||
.push(format!("https://steamcommunity.com/games/{appid}/rss/"));
|
text: Some(format!("Steam AppID {appid}")),
|
||||||
|
url: format!("https://steamcommunity.com/games/{appid}/rss/"),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.verify {
|
if args.verify {
|
||||||
|
@ -58,9 +70,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 response = ureq_agent.get(&potential_feed).call()?;
|
let response = ureq_agent.get(&potential_feed.url).call()?;
|
||||||
if response.content_type() == "text/xml" {
|
if response.content_type() == "text/xml" {
|
||||||
feeds_to_output.push(potential_feed);
|
let body = response.into_string()?;
|
||||||
|
let title_start = body.find("<title>").unwrap() + 7;
|
||||||
|
let title_end = body.find("</title>").unwrap();
|
||||||
|
feeds_to_output.push(Feed {
|
||||||
|
text: Some(body[title_start..title_end].to_string()),
|
||||||
|
url: potential_feed.url,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(timeout);
|
sleep(timeout);
|
||||||
|
@ -71,11 +89,14 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut opml_document = opml::OPML::default();
|
let mut opml_document = opml::OPML::default();
|
||||||
|
opml_document.head = None;
|
||||||
|
|
||||||
for feed in feeds_to_output {
|
for feed in feeds_to_output {
|
||||||
if args.opml {
|
if args.opml {
|
||||||
opml_document.add_feed(&feed, &feed);
|
opml_document
|
||||||
|
.add_feed(&feed.text.unwrap_or_else(|| feed.url.clone()), &feed.url);
|
||||||
} else {
|
} else {
|
||||||
println!("{feed}");
|
println!("{}", feed.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue