mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Add setting to allow nsfw images (#264)
This commit is contained in:
@@ -7,6 +7,7 @@ enabled = true
|
||||
prefer_animated = false
|
||||
banned_images = []
|
||||
only_download_boilr_images = false
|
||||
allow_nsfw = false
|
||||
|
||||
[steam]
|
||||
create_collections = false
|
||||
|
||||
@@ -204,7 +204,7 @@ async fn search_for_images_to_download(
|
||||
|
||||
for image_ids in image_ids.chunks(99) {
|
||||
let image_search_result =
|
||||
get_images_for_ids(client, image_ids, &image_type, download_animated).await;
|
||||
get_images_for_ids(client, image_ids, &image_type, download_animated, settings.steamgrid_db.allow_nsfw).await;
|
||||
match image_search_result {
|
||||
Ok(images) => {
|
||||
let images = images
|
||||
@@ -261,9 +261,10 @@ async fn get_images_for_ids(
|
||||
image_ids: &[usize],
|
||||
image_type: &ImageType,
|
||||
download_animated: bool,
|
||||
allow_nsfw: bool,
|
||||
) -> Result<Vec<steamgriddb_api::response::SteamGridDbResult<steamgriddb_api::images::Image>>, String>
|
||||
{
|
||||
let query_type = get_query_type(download_animated, image_type);
|
||||
let query_type = get_query_type(download_animated, image_type, allow_nsfw);
|
||||
|
||||
let image_search_result = client.get_images_for_ids(image_ids, &query_type).await;
|
||||
|
||||
@@ -275,6 +276,7 @@ const BIG_PICTURE_DIMS: [GridDimentions; 2] = [GridDimentions::D920x430, GridDim
|
||||
pub fn get_query_type(
|
||||
download_animated: bool,
|
||||
image_type: &ImageType,
|
||||
allow_nsfw: bool,
|
||||
) -> steamgriddb_api::QueryType {
|
||||
let anymation_type = if download_animated {
|
||||
Some(&[steamgriddb_api::query_parameters::AnimtionType::Animated][..])
|
||||
@@ -282,33 +284,37 @@ pub fn get_query_type(
|
||||
None
|
||||
};
|
||||
use steamgriddb_api::query_parameters::GridQueryParameters;
|
||||
let allow_nsfw_enum = match allow_nsfw {
|
||||
true => Some(&Nsfw::Any),
|
||||
false => Some(&Nsfw::False),
|
||||
};
|
||||
let big_picture_parameters = GridQueryParameters {
|
||||
dimentions: Some(&BIG_PICTURE_DIMS),
|
||||
types: anymation_type,
|
||||
nsfw: Some(&Nsfw::False),
|
||||
nsfw: allow_nsfw_enum,
|
||||
..Default::default()
|
||||
};
|
||||
use steamgriddb_api::query_parameters::HeroQueryParameters;
|
||||
let hero_parameters = HeroQueryParameters {
|
||||
types: anymation_type,
|
||||
nsfw: Some(&Nsfw::False),
|
||||
nsfw: allow_nsfw_enum,
|
||||
..Default::default()
|
||||
};
|
||||
let grid_parameters = GridQueryParameters {
|
||||
types: anymation_type,
|
||||
nsfw: Some(&Nsfw::False),
|
||||
nsfw: allow_nsfw_enum,
|
||||
..Default::default()
|
||||
};
|
||||
use steamgriddb_api::query_parameters::LogoQueryParameters;
|
||||
let logo_parameters = LogoQueryParameters {
|
||||
types: anymation_type,
|
||||
nsfw: Some(&Nsfw::False),
|
||||
nsfw: allow_nsfw_enum,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
use steamgriddb_api::query_parameters::IconQueryParameters;
|
||||
let icon_parameters = IconQueryParameters {
|
||||
nsfw: Some(&Nsfw::False),
|
||||
nsfw: allow_nsfw_enum,
|
||||
..Default::default()
|
||||
};
|
||||
let query_type = match image_type {
|
||||
|
||||
@@ -9,6 +9,7 @@ pub struct SteamGridDbSettings {
|
||||
pub prefer_animated: bool,
|
||||
pub banned_images: Vec<String>,
|
||||
pub only_download_boilr_images: bool,
|
||||
pub allow_nsfw: bool,
|
||||
}
|
||||
|
||||
impl SteamGridDbSettings {
|
||||
|
||||
@@ -619,7 +619,7 @@ impl MyEguiApp {
|
||||
self.rt.spawn_blocking(move || {
|
||||
let thumbnails_folder = get_thumbnails_folder();
|
||||
let client = steamgriddb_api::Client::new(auth_key);
|
||||
let query = get_query_type(false, &image_type);
|
||||
let query = get_query_type(false, &image_type, settings.steamgrid_db.allow_nsfw);
|
||||
let search_res = block_on(client.get_images_for_id(grid_id, &query));
|
||||
if let Ok(possible_images) = search_res {
|
||||
let mut result = vec![];
|
||||
|
||||
@@ -117,6 +117,7 @@ impl MyEguiApp {
|
||||
&mut self.settings.steamgrid_db.only_download_boilr_images,
|
||||
"Only download images for BoilR shortcuts",
|
||||
);
|
||||
ui.checkbox(&mut self.settings.steamgrid_db.allow_nsfw, "Allow NSFW images");
|
||||
}
|
||||
ui.add_space(SECTION_SPACING);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user