Compare commits
	
		
			No commits in common. "bcf390e9b6e30f9999184350d59c8c965676919b" and "b4f75b149a75e49aff70674a3eb61f2a5b620d82" have entirely different histories.
		
	
	
		
			bcf390e9b6
			...
			b4f75b149a
		
	
		
					 3 changed files with 4 additions and 21 deletions
				
			
		
							
								
								
									
										12
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
					@ -1,14 +1,2 @@
 | 
				
			||||||
Steam Game Picker
 | 
					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. Run the command
 | 
					 | 
				
			||||||
    * Pick any game: `./steam_game_picker`
 | 
					 | 
				
			||||||
    * Pick an unplayed game: `./steam_game_picker --unplayed`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,8 +5,6 @@ use serde::Serialize;
 | 
				
			||||||
use std::fs::File;
 | 
					use std::fs::File;
 | 
				
			||||||
use std::io::Read;
 | 
					use std::io::Read;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const STEAM_API_URL: &str = "https://api.steampowered.com";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[derive(Serialize, Deserialize)]
 | 
					#[derive(Serialize, Deserialize)]
 | 
				
			||||||
pub struct User {
 | 
					pub struct User {
 | 
				
			||||||
    pub username: String,
 | 
					    pub username: String,
 | 
				
			||||||
| 
						 | 
					@ -20,8 +18,8 @@ pub struct Config {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Config {
 | 
					impl Config {
 | 
				
			||||||
    pub fn new() -> Config {
 | 
					    pub fn new() -> Config {
 | 
				
			||||||
        let mut contents = String::new();
 | 
					 | 
				
			||||||
        let mut config_file = File::open("config.toml").expect("Failed to open config.toml");
 | 
					        let mut config_file = File::open("config.toml").expect("Failed to open config.toml");
 | 
				
			||||||
 | 
					        let mut contents = String::new();
 | 
				
			||||||
        config_file
 | 
					        config_file
 | 
				
			||||||
            .read_to_string(&mut contents)
 | 
					            .read_to_string(&mut contents)
 | 
				
			||||||
            .expect("Failed to read config.toml");
 | 
					            .expect("Failed to read config.toml");
 | 
				
			||||||
| 
						 | 
					@ -36,8 +34,8 @@ impl Config {
 | 
				
			||||||
    pub fn get_steam_id(&self, username: Option<&String>) -> String {
 | 
					    pub fn get_steam_id(&self, username: Option<&String>) -> String {
 | 
				
			||||||
        let username = username.unwrap_or(&self.user.username);
 | 
					        let username = username.unwrap_or(&self.user.username);
 | 
				
			||||||
        match reqwest::blocking::get(format!(
 | 
					        match reqwest::blocking::get(format!(
 | 
				
			||||||
            "{}/ISteamUser/ResolveVanityURL/v0001/?key={}&vanityurl={}",
 | 
					            "https://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key={}&vanityurl={}",
 | 
				
			||||||
            STEAM_API_URL, self.steam_api_key, username
 | 
					            self.steam_api_key, username
 | 
				
			||||||
        )) {
 | 
					        )) {
 | 
				
			||||||
            Ok(res) => match res.text() {
 | 
					            Ok(res) => match res.text() {
 | 
				
			||||||
                Ok(text) => {
 | 
					                Ok(text) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,8 +4,6 @@ use crate::responses::api_response::ApiResponse;
 | 
				
			||||||
use rand::seq::IteratorRandom;
 | 
					use rand::seq::IteratorRandom;
 | 
				
			||||||
use serde::{Deserialize, Serialize};
 | 
					use serde::{Deserialize, Serialize};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const STEAM_API_URL: &str = "https://api.steampowered.com";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[derive(Serialize, Deserialize)]
 | 
					#[derive(Serialize, Deserialize)]
 | 
				
			||||||
pub struct GameList {
 | 
					pub struct GameList {
 | 
				
			||||||
    pub game_count: i32,
 | 
					    pub game_count: i32,
 | 
				
			||||||
| 
						 | 
					@ -22,8 +20,7 @@ impl GameList {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn update(&mut self) {
 | 
					    pub fn update(&mut self) {
 | 
				
			||||||
        let config = Config::new();
 | 
					        let config = Config::new();
 | 
				
			||||||
        match reqwest::blocking::get(format!("{}/IPlayerService/GetOwnedGames/v0001/?key={}&steamid={}&format=json&include_appinfo=true",
 | 
					        match reqwest::blocking::get(format!("https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={}&steamid={}&format=json&include_appinfo=true",
 | 
				
			||||||
                                             STEAM_API_URL,
 | 
					 | 
				
			||||||
                                             config.steam_api_key,
 | 
					                                             config.steam_api_key,
 | 
				
			||||||
                                             config.get_steam_id(Some(&config.user.username))
 | 
					                                             config.get_steam_id(Some(&config.user.username))
 | 
				
			||||||
        )) {
 | 
					        )) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue