mirror of
https://github.com/Death916/deathclock.git
synced 2026-04-10 03:04:40 -07:00
get mlb logos
This commit is contained in:
parent
3740fce8d2
commit
00ab2bb522
2 changed files with 16 additions and 1 deletions
|
|
@ -174,7 +174,7 @@ impl State {
|
|||
|
||||
impl Default for State {
|
||||
fn default() -> Self {
|
||||
sports::update_mlb();
|
||||
sports::get_mlb_logos();
|
||||
|
||||
let text = ureq::get("https://v2.wttr.in/Sacramento.png?u0")
|
||||
.header("User-Agent", "deathclock-app/1.0")
|
||||
|
|
|
|||
|
|
@ -136,3 +136,18 @@ pub fn update_nba() -> Vec<Game> {
|
|||
}
|
||||
updated_games
|
||||
}
|
||||
|
||||
pub fn get_mlb_logos() {
|
||||
let json = std::fs::read_to_string("src/files/mlb_logos.json").unwrap();
|
||||
let parsed_json: serde_json::Value = serde_json::from_str(&json).unwrap();
|
||||
let teams = parsed_json.as_array().unwrap();
|
||||
|
||||
let mut logos_map = std::collections::HashMap::new();
|
||||
for team in teams {
|
||||
let team_name = team["name"].as_str().unwrap();
|
||||
let logo_url = team["logo"].as_str().unwrap();
|
||||
println!("Team Name: {}", team_name);
|
||||
println!("Logo URL: {}", logo_url);
|
||||
logos_map.insert(team_name.to_string(), logo_url.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue