aboutsummaryrefslogtreecommitdiffstats
path: root/src/live.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-06-20 16:02:12 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2023-06-20 16:02:12 +0100
commit27baf0ab8005eed210a34d87a1c1f10b3f351d75 (patch)
treeca34782b1ef225583c68378f367ea4ba31eebc44 /src/live.rs
parent5de43f2c45e02396cfe46f5b8a3a00453efd8c4a (diff)
downloadblossom-27baf0ab8005eed210a34d87a1c1f10b3f351d75.tar.gz
blossom-27baf0ab8005eed210a34d87a1c1f10b3f351d75.tar.bz2
blossom-27baf0ab8005eed210a34d87a1c1f10b3f351d75.zip
add is_live check
Diffstat (limited to 'src/live.rs')
-rw-r--r--src/live.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/live.rs b/src/live.rs
new file mode 100644
index 0000000..4efb0d9
--- /dev/null
+++ b/src/live.rs
@@ -0,0 +1,21 @@
+use reqwest::Client;
+use serde::Deserialize;
+
+use crate::Result;
+
+#[derive(Deserialize, Default)]
+#[serde(rename_all = "camelCase")]
+pub struct LiveStatus {
+ pub online: bool,
+ pub viewer_count: u32,
+}
+
+pub async fn get_live_status(client: &Client) -> Result<LiveStatus> {
+ let endpoint = "https://weirdstar.stream/api/status";
+ Ok(client
+ .get(endpoint)
+ .send()
+ .await?
+ .json::<LiveStatus>()
+ .await?)
+}