Add Serde, JSON and SteamApp stuff.
This commit is contained in:
parent
e543f0aac0
commit
252fb17d56
|
@ -306,6 +306,12 @@ dependencies = [
|
|||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
|
||||
|
||||
[[package]]
|
||||
name = "jetscii"
|
||||
version = "0.5.3"
|
||||
|
@ -505,6 +511,12 @@ dependencies = [
|
|||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.0"
|
||||
|
@ -535,6 +547,17 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
|
@ -559,6 +582,8 @@ dependencies = [
|
|||
"indicatif",
|
||||
"opml",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"ureq",
|
||||
]
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ color-eyre = "0.6.2"
|
|||
indicatif = "0.17.1"
|
||||
opml = "1.1.4"
|
||||
regex = "1.6.0"
|
||||
serde = "1.0.144"
|
||||
serde_json = "1.0.85"
|
||||
ureq = "2.5.0"
|
||||
|
||||
[dependencies.clap]
|
||||
|
|
|
@ -14,6 +14,8 @@ use {
|
|||
color_eyre::{install, Result},
|
||||
indicatif::{ProgressBar, ProgressStyle},
|
||||
regex::Regex,
|
||||
serde::Deserialize,
|
||||
serde_json::Value,
|
||||
};
|
||||
|
||||
/// CLI arguments struct using [`clap`]'s Derive API.
|
||||
|
@ -39,11 +41,19 @@ pub struct Args {
|
|||
/// A game's store URL, can be used multiple times.
|
||||
#[clap(long)]
|
||||
pub url: Vec<String>,
|
||||
|
||||
/// A person's steamcommunity.com ID or full URL, can be used multiple times.
|
||||
#[clap(long)]
|
||||
pub user: Vec<String>,
|
||||
}
|
||||
|
||||
/// A simple feed struct.
|
||||
#[derive(Debug)]
|
||||
pub struct Feed {
|
||||
/// A potential alternate friendly URL, see [`SteamApp::friendly_url`] for an
|
||||
/// explanation.
|
||||
pub friendly_url: Option<String>,
|
||||
|
||||
/// The text to use for the feed in the OPML output.
|
||||
pub text: Option<String>,
|
||||
|
||||
|
@ -51,6 +61,29 @@ pub struct Feed {
|
|||
pub url: String,
|
||||
}
|
||||
|
||||
/// A small representation of a Steam game that is parsed from JSON.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SteamApp {
|
||||
/// The AppID of the game.
|
||||
pub appid: usize,
|
||||
|
||||
/// The name of the game.
|
||||
pub name: String,
|
||||
|
||||
/// A friendly URL name of the game, some feeds will use this instead of their
|
||||
/// AppID for their RSS feed.
|
||||
///
|
||||
/// For example, [Portal's feed](https://steamcommunity.com/games/Portal/rss)
|
||||
/// uses `Portal`, instead of
|
||||
/// [its AppID 400](https://steamcommunity.com/games/400/rss).
|
||||
///
|
||||
/// Some games may also have a friendly URL different from their AppID but
|
||||
/// don't use it for their feed. Steam is weird.
|
||||
#[serde(rename = "friendlyURL")]
|
||||
pub friendly_url: Value,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
install()?;
|
||||
|
||||
|
@ -68,6 +101,7 @@ fn main() -> Result<()> {
|
|||
|
||||
for appid in args.appid {
|
||||
potential_feeds.push(Feed {
|
||||
friendly_url: None,
|
||||
text: Some(format!("Steam AppID {appid}")),
|
||||
url: appid_to_rss_url(appid),
|
||||
});
|
||||
|
@ -80,6 +114,7 @@ fn main() -> Result<()> {
|
|||
.and_then(|appid_match| appid_match.as_str().parse::<usize>().ok());
|
||||
if let Some(appid) = appid {
|
||||
potential_feeds.push(Feed {
|
||||
friendly_url: None,
|
||||
text: Some(format!("Steam AppID {appid}")),
|
||||
url: appid_to_rss_url(appid),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue