offline mode almost there
This commit is contained in:
@@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::config::Config;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct JellyfinClient {
|
||||
base_url: String,
|
||||
@@ -112,6 +114,35 @@ impl JellyfinClient {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn ping_base_url(base_url: &str) -> bool {
|
||||
// Fast, unauthenticated check. Latch result at startup.
|
||||
// We try a couple endpoints because Jellyfin setups vary.
|
||||
let base = base_url.trim_end_matches('/');
|
||||
|
||||
let client = match reqwest::blocking::Client::builder()
|
||||
.timeout(Duration::from_millis(900))
|
||||
.build()
|
||||
{
|
||||
Ok(c) => c,
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
let candidates = [
|
||||
format!("{base}/System/Ping"),
|
||||
format!("{base}/System/Info/Public"),
|
||||
];
|
||||
|
||||
for url in candidates {
|
||||
if let Ok(resp) = client.get(url).send() {
|
||||
if resp.status().is_success() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
pub fn list_views(&self, user_id: &str) -> Result<Vec<JfItem>, String> {
|
||||
let url = format!("{}/Users/{}/Views", self.base_url, user_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user