feat: Initial working prototype
This commit is contained in:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user