diff options
Diffstat (limited to 'src/http/shiggy.rs')
| -rw-r--r-- | src/http/shiggy.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/http/shiggy.rs b/src/http/shiggy.rs new file mode 100644 index 0000000..397d397 --- /dev/null +++ b/src/http/shiggy.rs @@ -0,0 +1,20 @@ +use eyre::Result; +use serde::Deserialize; + +const SHIGGY: &str = "https://safebooru.donmai.us"; +const RANDOM: &str = "/posts/random.json?tags=kemomimi-chan_(naga_u)+naga_u&only=file_url"; + +#[derive(Deserialize)] +struct SafebooruResponse { + file_url: String, +} + +pub async fn random<T>(http: &T) -> Result<String> +where + T: super::Ext, +{ + let url = format!("{SHIGGY}{RANDOM}"); + let resp: SafebooruResponse = http.get_json(&url).await?; + + Ok(resp.file_url) +} |
