mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Download bigpicture images for games
This commit is contained in:
@@ -3,11 +3,12 @@ use std::io::Write;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{collections::HashMap, path::Path};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use futures::{stream, StreamExt}; // 0.3.1
|
use futures::{stream, StreamExt};
|
||||||
|
use steamgriddb_api::query_parameters::GridDimentions; // 0.3.1
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||||
use steamgriddb_api::Client;
|
use steamgriddb_api::{Client, QueryType};
|
||||||
|
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::steam::{get_shortcuts_for_user, get_users_images, SteamUsersInfo};
|
use crate::steam::{get_shortcuts_for_user, get_users_images, SteamUsersInfo};
|
||||||
@@ -80,6 +81,7 @@ async fn search_fo_to_download(
|
|||||||
format!("{}_hero.png", s.app_id),
|
format!("{}_hero.png", s.app_id),
|
||||||
format!("{}p.png", s.app_id),
|
format!("{}p.png", s.app_id),
|
||||||
format!("{}_logo.png", s.app_id),
|
format!("{}_logo.png", s.app_id),
|
||||||
|
format!("{}_bigpicture.png", s.app_id),
|
||||||
];
|
];
|
||||||
// if we are missing any of the images we need to search for them
|
// if we are missing any of the images we need to search for them
|
||||||
images.iter().any(|image| !known_images.contains(image)) && !s.app_name.is_empty()
|
images.iter().any(|image| !known_images.contains(image)) && !s.app_name.is_empty()
|
||||||
@@ -106,7 +108,7 @@ async fn search_fo_to_download(
|
|||||||
for (app_id, search) in search_results_a.into_iter().flatten() {
|
for (app_id, search) in search_results_a.into_iter().flatten() {
|
||||||
search_results.insert(app_id, search);
|
search_results.insert(app_id, search);
|
||||||
}
|
}
|
||||||
let types = vec![ImageType::Logo, ImageType::Hero, ImageType::Grid];
|
let types = vec![ImageType::Logo, ImageType::Hero, ImageType::Grid, ImageType::BigPicture];
|
||||||
let mut to_download = vec![];
|
let mut to_download = vec![];
|
||||||
for image_type in types {
|
for image_type in types {
|
||||||
let mut images_needed = shortcuts
|
let mut images_needed = shortcuts
|
||||||
@@ -119,8 +121,16 @@ async fn search_fo_to_download(
|
|||||||
.copied()
|
.copied()
|
||||||
.collect();
|
.collect();
|
||||||
use steamgriddb_api::query_parameters::QueryType::*;
|
use steamgriddb_api::query_parameters::QueryType::*;
|
||||||
|
let big_picture_dims = [GridDimentions::D920x430, GridDimentions::D460x215];
|
||||||
|
let big_picture_parameters = steamgriddb_api::query_parameters::GridQueryParameters{
|
||||||
|
dimentions: Some(&big_picture_dims),
|
||||||
|
..Default::default()
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
let query_type = match image_type {
|
let query_type = match image_type {
|
||||||
ImageType::Hero => Hero(None),
|
ImageType::Hero => Hero(None),
|
||||||
|
ImageType::BigPicture => Grid(Some(big_picture_parameters)),
|
||||||
ImageType::Grid => Grid(None),
|
ImageType::Grid => Grid(None),
|
||||||
ImageType::Logo => Logo(None),
|
ImageType::Logo => Logo(None),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ pub enum ImageType {
|
|||||||
Hero,
|
Hero,
|
||||||
Grid,
|
Grid,
|
||||||
Logo,
|
Logo,
|
||||||
|
BigPicture
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImageType {
|
impl ImageType {
|
||||||
@@ -12,6 +13,7 @@ impl ImageType {
|
|||||||
ImageType::Hero => format!("{}_hero.png", app_id),
|
ImageType::Hero => format!("{}_hero.png", app_id),
|
||||||
ImageType::Grid => format!("{}p.png", app_id),
|
ImageType::Grid => format!("{}p.png", app_id),
|
||||||
ImageType::Logo => format!("{}_logo.png", app_id),
|
ImageType::Logo => format!("{}_logo.png", app_id),
|
||||||
|
ImageType::BigPicture => format!("{}_bigpicture.png", app_id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ fn fix_shortcut_icons(user: &SteamUsersInfo, shortcuts: &mut Vec<ShortcutOwned>)
|
|||||||
&shortcut.app_name,
|
&shortcut.app_name,
|
||||||
);
|
);
|
||||||
let new_icon = image_folder
|
let new_icon = image_folder
|
||||||
.join(format!("{}p.png", app_id))
|
.join(format!("{}_bigpicture.png", app_id))
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
shortcut.icon = new_icon;
|
shortcut.icon = new_icon;
|
||||||
|
|||||||
Reference in New Issue
Block a user