feat: Initial working prototype
Some checks failed
build / checks-matrix (push) Has been cancelled
build / checks-build (push) Has been cancelled
build / codecov (push) Has been cancelled
docs / docs (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-11-19 01:39:20 +05:30
parent 3222c26bb6
commit a1c36e4fb2
10 changed files with 269 additions and 76 deletions

View File

@@ -24,7 +24,7 @@ type Result<T, E = JellyfinApiError> = std::result::Result<T, E>;
pub struct JellyfinClient {
client: reqwest::Client,
access_token: Option<Arc<str>>,
config: Arc<JellyfinConfig>,
pub config: Arc<JellyfinConfig>,
}
impl JellyfinClient {
@@ -56,7 +56,7 @@ impl JellyfinClient {
Ok(token)
}
pub async fn set_token(&mut self, token: impl AsRef<str>) {
pub fn set_token(&mut self, token: impl AsRef<str>) {
self.access_token = Some(token.as_ref().into());
}
@@ -143,10 +143,11 @@ impl JellyfinClient {
.await
.inspect_err(|err| tracing::warn!("Failed to load cached token: {}", err))
{
self.authenticate().await?;
self.save_token(path).await?;
tracing::info!("Authenticating with cached token from {:?}", path);
self.access_token = Some(token.clone().into());
Ok(token)
} else {
tracing::info!("No cached token found at {:?}, authenticating...", path);
let token = self
.authenticate()
.await?