diff --git a/src/defaultconfig.toml b/src/defaultconfig.toml index 1bbdfb0..8482d31 100644 --- a/src/defaultconfig.toml +++ b/src/defaultconfig.toml @@ -7,6 +7,7 @@ enabled = true prefer_animated = false banned_images = [] only_download_boilr_images = false +allow_nsfw = false [steam] create_collections = false diff --git a/src/steamgriddb/downloader.rs b/src/steamgriddb/downloader.rs index 4e74473..a4f4eec 100644 --- a/src/steamgriddb/downloader.rs +++ b/src/steamgriddb/downloader.rs @@ -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>, 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 { diff --git a/src/steamgriddb/settings.rs b/src/steamgriddb/settings.rs index 9073b0b..bbccb6a 100644 --- a/src/steamgriddb/settings.rs +++ b/src/steamgriddb/settings.rs @@ -9,6 +9,7 @@ pub struct SteamGridDbSettings { pub prefer_animated: bool, pub banned_images: Vec, pub only_download_boilr_images: bool, + pub allow_nsfw: bool, } impl SteamGridDbSettings { diff --git a/src/ui/ui_image_download.rs b/src/ui/ui_image_download.rs index 46a5537..939b8df 100644 --- a/src/ui/ui_image_download.rs +++ b/src/ui/ui_image_download.rs @@ -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![]; diff --git a/src/ui/ui_settings.rs b/src/ui/ui_settings.rs index 87be9db..d5735d7 100644 --- a/src/ui/ui_settings.rs +++ b/src/ui/ui_settings.rs @@ -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); }