Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
81b819996e | |||
bcf390e9b6 | |||
3610c1e53e |
3 changed files with 20 additions and 4 deletions
11
README.md
11
README.md
|
@ -1,2 +1,13 @@
|
|||
Steam Game Picker
|
||||
=================
|
||||
_________________
|
||||
|
||||
How to use
|
||||
===
|
||||
___
|
||||
|
||||
1. Download a [release](https://edbuildsthings.com/tiradoe/steam-game-picker/releases)
|
||||
2. Extract the files and update the information in `config.toml`
|
||||
3. Open a terminal, navigate to the directory with the extracted files, and run the command
|
||||
* Pick any game: `./steam_game_picker`
|
||||
* Pick an unplayed game: `./steam_game_picker --unplayed`
|
||||
|
|
|
@ -5,6 +5,8 @@ use serde::Serialize;
|
|||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
const STEAM_API_URL: &str = "https://api.steampowered.com";
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
pub username: String,
|
||||
|
@ -18,8 +20,8 @@ pub struct Config {
|
|||
|
||||
impl Config {
|
||||
pub fn new() -> Config {
|
||||
let mut config_file = File::open("config.toml").expect("Failed to open config.toml");
|
||||
let mut contents = String::new();
|
||||
let mut config_file = File::open("config.toml").expect("Failed to open config.toml");
|
||||
config_file
|
||||
.read_to_string(&mut contents)
|
||||
.expect("Failed to read config.toml");
|
||||
|
@ -34,8 +36,8 @@ impl Config {
|
|||
pub fn get_steam_id(&self, username: Option<&String>) -> String {
|
||||
let username = username.unwrap_or(&self.user.username);
|
||||
match reqwest::blocking::get(format!(
|
||||
"https://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key={}&vanityurl={}",
|
||||
self.steam_api_key, username
|
||||
"{}/ISteamUser/ResolveVanityURL/v0001/?key={}&vanityurl={}",
|
||||
STEAM_API_URL, self.steam_api_key, username
|
||||
)) {
|
||||
Ok(res) => match res.text() {
|
||||
Ok(text) => {
|
||||
|
|
|
@ -4,6 +4,8 @@ use crate::responses::api_response::ApiResponse;
|
|||
use rand::seq::IteratorRandom;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
const STEAM_API_URL: &str = "https://api.steampowered.com";
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct GameList {
|
||||
pub game_count: i32,
|
||||
|
@ -20,7 +22,8 @@ impl GameList {
|
|||
|
||||
pub fn update(&mut self) {
|
||||
let config = Config::new();
|
||||
match reqwest::blocking::get(format!("https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={}&steamid={}&format=json&include_appinfo=true",
|
||||
match reqwest::blocking::get(format!("{}/IPlayerService/GetOwnedGames/v0001/?key={}&steamid={}&format=json&include_appinfo=true",
|
||||
STEAM_API_URL,
|
||||
config.steam_api_key,
|
||||
config.get_steam_id(Some(&config.user.username))
|
||||
)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue