feat: Initial working prototype
This commit is contained in:
@@ -138,7 +138,7 @@ pub struct AlbumInfo {
|
||||
pub album_artists: Vec<String>,
|
||||
/// Gets or sets the artist provider ids.
|
||||
#[serde(rename = "ArtistProviderIds")]
|
||||
pub artist_provider_ids: std::collections::HashMap<String, Option<String>>,
|
||||
pub artist_provider_ids: Option<std::collections::HashMap<String, Option<String>>>,
|
||||
#[serde(rename = "SongInfos")]
|
||||
pub song_infos: Vec<SongInfo>,
|
||||
}
|
||||
@@ -592,7 +592,7 @@ Maps image type to dictionary mapping image tag to blurhash value.*/
|
||||
pub trickplay: Option<
|
||||
std::collections::HashMap<
|
||||
String,
|
||||
std::collections::HashMap<String, TrickplayInfo>,
|
||||
Option<std::collections::HashMap<String, TrickplayInfo>>,
|
||||
>,
|
||||
>,
|
||||
/// Gets or sets the type of the location.
|
||||
@@ -729,31 +729,31 @@ Maps image type to dictionary mapping image tag to blurhash value.*/
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct BaseItemDtoImageBlurHashes {
|
||||
#[serde(rename = "Primary")]
|
||||
pub primary: std::collections::HashMap<String, String>,
|
||||
pub primary: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Art")]
|
||||
pub art: std::collections::HashMap<String, String>,
|
||||
pub art: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Backdrop")]
|
||||
pub backdrop: std::collections::HashMap<String, String>,
|
||||
pub backdrop: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Banner")]
|
||||
pub banner: std::collections::HashMap<String, String>,
|
||||
pub banner: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Logo")]
|
||||
pub logo: std::collections::HashMap<String, String>,
|
||||
pub logo: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Thumb")]
|
||||
pub thumb: std::collections::HashMap<String, String>,
|
||||
pub thumb: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Disc")]
|
||||
pub disc: std::collections::HashMap<String, String>,
|
||||
pub disc: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Box")]
|
||||
pub _box: std::collections::HashMap<String, String>,
|
||||
pub _box: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Screenshot")]
|
||||
pub screenshot: std::collections::HashMap<String, String>,
|
||||
pub screenshot: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Menu")]
|
||||
pub menu: std::collections::HashMap<String, String>,
|
||||
pub menu: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Chapter")]
|
||||
pub chapter: std::collections::HashMap<String, String>,
|
||||
pub chapter: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "BoxRear")]
|
||||
pub box_rear: std::collections::HashMap<String, String>,
|
||||
pub box_rear: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Profile")]
|
||||
pub profile: std::collections::HashMap<String, String>,
|
||||
pub profile: Option<std::collections::HashMap<String, String>>,
|
||||
}
|
||||
/// Query result container.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
@@ -794,31 +794,31 @@ pub struct BaseItemPerson {
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct BaseItemPersonImageBlurHashes {
|
||||
#[serde(rename = "Primary")]
|
||||
pub primary: std::collections::HashMap<String, String>,
|
||||
pub primary: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Art")]
|
||||
pub art: std::collections::HashMap<String, String>,
|
||||
pub art: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Backdrop")]
|
||||
pub backdrop: std::collections::HashMap<String, String>,
|
||||
pub backdrop: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Banner")]
|
||||
pub banner: std::collections::HashMap<String, String>,
|
||||
pub banner: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Logo")]
|
||||
pub logo: std::collections::HashMap<String, String>,
|
||||
pub logo: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Thumb")]
|
||||
pub thumb: std::collections::HashMap<String, String>,
|
||||
pub thumb: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Disc")]
|
||||
pub disc: std::collections::HashMap<String, String>,
|
||||
pub disc: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Box")]
|
||||
pub _box: std::collections::HashMap<String, String>,
|
||||
pub _box: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Screenshot")]
|
||||
pub screenshot: std::collections::HashMap<String, String>,
|
||||
pub screenshot: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Menu")]
|
||||
pub menu: std::collections::HashMap<String, String>,
|
||||
pub menu: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Chapter")]
|
||||
pub chapter: std::collections::HashMap<String, String>,
|
||||
pub chapter: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "BoxRear")]
|
||||
pub box_rear: std::collections::HashMap<String, String>,
|
||||
pub box_rear: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(rename = "Profile")]
|
||||
pub profile: std::collections::HashMap<String, String>,
|
||||
pub profile: Option<std::collections::HashMap<String, String>>,
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct BookInfo {
|
||||
@@ -1362,7 +1362,7 @@ pub struct DisplayPreferencesDto {
|
||||
pub primary_image_width: i32,
|
||||
/// Gets or sets the custom prefs.
|
||||
#[serde(rename = "CustomPrefs")]
|
||||
pub custom_prefs: std::collections::HashMap<String, Option<String>>,
|
||||
pub custom_prefs: Option<std::collections::HashMap<String, Option<String>>>,
|
||||
/// Gets or sets the scroll direction.
|
||||
#[serde(rename = "ScrollDirection")]
|
||||
pub scroll_direction: ScrollDirection,
|
||||
@@ -1640,7 +1640,7 @@ pub struct GeneralCommand {
|
||||
#[serde(rename = "ControllingUserId")]
|
||||
pub controlling_user_id: uuid::Uuid,
|
||||
#[serde(rename = "Arguments")]
|
||||
pub arguments: std::collections::HashMap<String, Option<String>>,
|
||||
pub arguments: Option<std::collections::HashMap<String, Option<String>>>,
|
||||
}
|
||||
/// General command websocket message.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
@@ -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