feat: Added typegen for jellyfin structs and enums
This commit is contained in:
104
api/src/lib.rs
104
api/src/lib.rs
@@ -1,3 +1,4 @@
|
||||
pub mod jellyfin;
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum JellyfinApiError {
|
||||
@@ -28,15 +29,16 @@ impl JellyfinClient {
|
||||
.header("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
// pub async fn authenticate(&mut self) -> Result<()> {
|
||||
// self.post("Users/AuthenticateByName")
|
||||
// .json(AuthenticateUserByName {
|
||||
// username: self.config.username.clone(),
|
||||
// pw: self.config.password.clone(),
|
||||
// })
|
||||
// .send()
|
||||
// .await
|
||||
// }
|
||||
pub async fn authenticate(&mut self) -> Result<()> {
|
||||
self.post("Users/AuthenticateByName")
|
||||
.json(&jellyfin::AuthenticateUserByName {
|
||||
username: Some(self.config.username.clone()),
|
||||
pw: Some(self.config.password.clone()),
|
||||
})
|
||||
.send()
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
@@ -46,87 +48,3 @@ pub struct JellyfinConfig {
|
||||
pub server_url: iref::IriBuf,
|
||||
pub device_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct AuthenticationResult {
|
||||
user: UserDto,
|
||||
session_info: Option<SessionInfoDto>,
|
||||
access_token: Option<String>,
|
||||
server_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct UserDto {}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct SerssionInfoDto {}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct AuthenticateUserByName {
|
||||
username: String,
|
||||
pw: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct QuickConnectDto {
|
||||
secret: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
struct User {
|
||||
id: String,
|
||||
configuration: Configuration,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
struct Configuration {
|
||||
audio_language_preference: Option<String>,
|
||||
play_default_audio_track: bool,
|
||||
subtitle_language_preference: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
struct Items {
|
||||
items: Vec<MediaItem>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct MediaItem {
|
||||
// #[serde(rename = "Id")]
|
||||
pub id: String,
|
||||
// #[serde(rename = "Name")]
|
||||
pub name: String,
|
||||
// #[serde(rename = "Type")]
|
||||
pub type_: String,
|
||||
// #[serde(rename = "Path")]
|
||||
pub path: Option<String>,
|
||||
// #[serde(rename = "CollectionType")]
|
||||
pub collection_type: Option<String>,
|
||||
// #[serde(rename = "ProductionYear")]
|
||||
pub year: Option<i32>,
|
||||
// #[serde(rename = "Overview")]
|
||||
pub overview: Option<String>,
|
||||
// #[serde(rename = "CommunityRating")]
|
||||
pub imdb_rating: Option<f32>,
|
||||
// #[serde(rename = "CriticRating")]
|
||||
pub critic_rating: Option<i32>,
|
||||
// #[serde(rename = "RunTimeTicks")]
|
||||
pub runtime_ticks: Option<i64>,
|
||||
// #[serde(rename = "SeriesId")]
|
||||
pub series_id: Option<String>,
|
||||
// #[serde(rename = "SeriesName")]
|
||||
pub series_name: Option<String>,
|
||||
// #[serde(rename = "ParentIndexNumber")]
|
||||
pub parent_index_number: Option<i64>,
|
||||
// #[serde(rename = "IndexNumber")]
|
||||
pub index_number: Option<i64>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user