mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 14:03:42 +02:00
Remove unused imports
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
[target.x86_64-pc-windows-gnu]
|
||||||
|
linker = "/usr/bin/x86_64-w64-mingw32-gcc"
|
||||||
|
ar = "/usr/x86_64-w64-mingw32/bin/ar"
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
use super::{EpicGamesLauncherSettings, ManifestItem};
|
use super::{EpicGamesLauncherSettings, ManifestItem};
|
||||||
use std::env::{self, VarError};
|
#[cfg(target_os = "windows")]
|
||||||
use std::error::Error;
|
use std::env::{self};
|
||||||
|
|
||||||
use std::fs::{DirEntry, File};
|
use std::fs::{DirEntry, File};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -9,6 +10,7 @@ use failure::*;
|
|||||||
|
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum EpicGamesManifestsError {
|
pub enum EpicGamesManifestsError {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
#[fail(display = "Path to EpicGamesLauncher not defined, it must be defined on linux")]
|
#[fail(display = "Path to EpicGamesLauncher not defined, it must be defined on linux")]
|
||||||
PathNotDefined,
|
PathNotDefined,
|
||||||
|
|
||||||
|
|||||||
+11
-79
@@ -1,13 +1,5 @@
|
|||||||
use crate::steamgriddb::{CachedSearch, ImageType};
|
use crate::steamgriddb::{download_images, CachedSearch};
|
||||||
use std::{
|
use std::{fs::File, io::Write, path::Path};
|
||||||
collections::HashMap,
|
|
||||||
env::{self},
|
|
||||||
fmt,
|
|
||||||
fs::File,
|
|
||||||
io::Write,
|
|
||||||
ops::Deref,
|
|
||||||
path::Path,
|
|
||||||
};
|
|
||||||
mod egs;
|
mod egs;
|
||||||
mod legendary;
|
mod legendary;
|
||||||
mod platform;
|
mod platform;
|
||||||
@@ -23,10 +15,7 @@ use crate::{
|
|||||||
steam::{get_shortcuts_for_user, get_shortcuts_paths, get_users_images},
|
steam::{get_shortcuts_for_user, get_shortcuts_paths, get_users_images},
|
||||||
};
|
};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use steam_shortcuts_util::{
|
use steam_shortcuts_util::{shortcut::ShortcutOwned, shortcuts_to_bytes, Shortcut};
|
||||||
parse_shortcuts, shortcut::ShortcutOwned, shortcuts_to_bytes, Shortcut,
|
|
||||||
};
|
|
||||||
use steamgriddb_api::{search::SearchResult, Client};
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error>> {
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
@@ -66,71 +55,14 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
save_shortcuts(&shortcuts, Path::new(&shortcut_info.path));
|
save_shortcuts(&shortcuts, Path::new(&shortcut_info.path));
|
||||||
|
|
||||||
let known_images = get_users_images(user).unwrap();
|
let known_images = get_users_images(user).unwrap();
|
||||||
|
download_images(
|
||||||
let shortcuts_to_search_for = shortcuts.iter().filter(|s| {
|
known_images,
|
||||||
let images = vec![
|
user.steam_user_data_folder.as_str(),
|
||||||
format!("{}_hero.png", s.app_id),
|
shortcuts,
|
||||||
format!("{}p.png", s.app_id),
|
&mut search,
|
||||||
format!("{}_logo.png", s.app_id),
|
&client,
|
||||||
];
|
)
|
||||||
// if we are missing any of the images we need to search for them
|
.await?;
|
||||||
images.iter().any(|image| !known_images.contains(&image))
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut search_results = HashMap::new();
|
|
||||||
for s in shortcuts_to_search_for {
|
|
||||||
println!("Searching for {}", s.app_name);
|
|
||||||
let search = search.search(s.app_id, s.app_name).await?;
|
|
||||||
if let Some(search) = search {
|
|
||||||
search_results.insert(s.app_id, search);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let types = vec![ImageType::Logo, ImageType::Hero, ImageType::Grid];
|
|
||||||
for image_type in types {
|
|
||||||
let mut images_needed = shortcuts
|
|
||||||
.iter()
|
|
||||||
.filter(|s| search_results.contains_key(&s.app_id))
|
|
||||||
.filter(|s| !known_images.contains(&image_type.file_name(s.app_id)));
|
|
||||||
let image_ids: Vec<usize> = images_needed
|
|
||||||
.clone()
|
|
||||||
.filter_map(|s| search_results.get(&s.app_id))
|
|
||||||
.map(|search| *search)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let query_type = match image_type {
|
|
||||||
ImageType::Hero => steamgriddb_api::query_parameters::QueryType::Hero(None),
|
|
||||||
ImageType::Grid => steamgriddb_api::query_parameters::QueryType::Grid(None),
|
|
||||||
ImageType::Logo => steamgriddb_api::query_parameters::QueryType::Logo(None),
|
|
||||||
};
|
|
||||||
|
|
||||||
match client
|
|
||||||
.get_images_for_ids(image_ids.as_slice(), &query_type)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(images) => {
|
|
||||||
for image in images {
|
|
||||||
if let Some(shortcut) = images_needed.next() {
|
|
||||||
if let Ok(image) = image {
|
|
||||||
let grid_folder = Path::new(user.steam_user_data_folder.as_str())
|
|
||||||
.join("config/grid");
|
|
||||||
let path = grid_folder.join(image_type.file_name(shortcut.app_id));
|
|
||||||
println!(
|
|
||||||
"Downloading {} to {}",
|
|
||||||
image.url,
|
|
||||||
path.as_path().to_str().unwrap()
|
|
||||||
);
|
|
||||||
let mut file = File::create(path).unwrap();
|
|
||||||
let response = reqwest::get(image.url).await?;
|
|
||||||
let content = response.bytes().await?;
|
|
||||||
file.write(&content).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => println!("Error getting images: {}", err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search.save();
|
search.save();
|
||||||
|
|||||||
+3
-8
@@ -1,17 +1,12 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
env::{self},
|
|
||||||
fmt,
|
fmt,
|
||||||
fs::File,
|
|
||||||
io::Write,
|
|
||||||
ops::Deref,
|
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use std::env::{self};
|
||||||
|
|
||||||
use steam_shortcuts_util::{
|
use steam_shortcuts_util::{parse_shortcuts, shortcut::ShortcutOwned};
|
||||||
parse_shortcuts, shortcut::ShortcutOwned, shortcuts_to_bytes, Shortcut,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn get_shortcuts_for_user(user: &SteamUsersInfo) -> ShortcutInfo {
|
pub fn get_shortcuts_for_user(user: &SteamUsersInfo) -> ShortcutInfo {
|
||||||
let mut shortcuts = vec![];
|
let mut shortcuts = vec![];
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
|
use std::error::Error;
|
||||||
|
use steam_shortcuts_util::Shortcut;
|
||||||
|
use steamgriddb_api::Client;
|
||||||
|
|
||||||
|
use crate::steamgriddb::ImageType;
|
||||||
|
|
||||||
|
use super::CachedSearch;
|
||||||
|
|
||||||
|
pub async fn download_images<'a, 'b>(
|
||||||
|
known_images: Vec<String>,
|
||||||
|
user_data_folder: &str,
|
||||||
|
shortcuts: Vec<Shortcut<'a>>,
|
||||||
|
search: &mut CachedSearch<'b>,
|
||||||
|
client: &Client,
|
||||||
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
let shortcuts_to_search_for = shortcuts.iter().filter(|s| {
|
||||||
|
let images = vec![
|
||||||
|
format!("{}_hero.png", s.app_id),
|
||||||
|
format!("{}p.png", s.app_id),
|
||||||
|
format!("{}_logo.png", s.app_id),
|
||||||
|
];
|
||||||
|
// if we are missing any of the images we need to search for them
|
||||||
|
images.iter().any(|image| !known_images.contains(&image))
|
||||||
|
});
|
||||||
|
let mut search_results = HashMap::new();
|
||||||
|
for s in shortcuts_to_search_for {
|
||||||
|
println!("Searching for {}", s.app_name);
|
||||||
|
let search = search.search(s.app_id, s.app_name).await?;
|
||||||
|
if let Some(search) = search {
|
||||||
|
search_results.insert(s.app_id, search);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let types = vec![ImageType::Logo, ImageType::Hero, ImageType::Grid];
|
||||||
|
Ok(for image_type in types {
|
||||||
|
let mut images_needed = shortcuts
|
||||||
|
.iter()
|
||||||
|
.filter(|s| search_results.contains_key(&s.app_id))
|
||||||
|
.filter(|s| !known_images.contains(&image_type.file_name(s.app_id)));
|
||||||
|
let image_ids: Vec<usize> = images_needed
|
||||||
|
.clone()
|
||||||
|
.filter_map(|s| search_results.get(&s.app_id))
|
||||||
|
.map(|search| *search)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let query_type = match image_type {
|
||||||
|
ImageType::Hero => steamgriddb_api::query_parameters::QueryType::Hero(None),
|
||||||
|
ImageType::Grid => steamgriddb_api::query_parameters::QueryType::Grid(None),
|
||||||
|
ImageType::Logo => steamgriddb_api::query_parameters::QueryType::Logo(None),
|
||||||
|
};
|
||||||
|
|
||||||
|
match client
|
||||||
|
.get_images_for_ids(image_ids.as_slice(), &query_type)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(images) => {
|
||||||
|
for image in images {
|
||||||
|
if let Some(shortcut) = images_needed.next() {
|
||||||
|
if let Ok(image) = image {
|
||||||
|
let grid_folder = Path::new(user_data_folder).join("config/grid");
|
||||||
|
let path = grid_folder.join(image_type.file_name(shortcut.app_id));
|
||||||
|
println!(
|
||||||
|
"Downloading {} to {}",
|
||||||
|
image.url,
|
||||||
|
path.as_path().to_str().unwrap()
|
||||||
|
);
|
||||||
|
let mut file = File::create(path).unwrap();
|
||||||
|
let response = reqwest::get(image.url).await?;
|
||||||
|
let content = response.bytes().await?;
|
||||||
|
file.write(&content).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => println!("Error getting images: {}", err),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
mod settings;
|
mod settings;
|
||||||
mod image_type;
|
mod image_type;
|
||||||
mod cached_search;
|
mod cached_search;
|
||||||
|
mod downloader;
|
||||||
|
|
||||||
pub use image_type::ImageType;
|
pub use image_type::ImageType;
|
||||||
pub use settings::SteamGridDbSettings;
|
pub use settings::SteamGridDbSettings;
|
||||||
pub use cached_search::CachedSearch;
|
pub use cached_search::CachedSearch;
|
||||||
|
pub use downloader::*;
|
||||||
Reference in New Issue
Block a user