aboutsummaryrefslogtreecommitdiffstats
path: root/src/live.rs
blob: 4efb0d9e8ac51aa5aab8809bd72e46efddd1a386 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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?)
}