61 lines
1.8 KiB
Rust
61 lines
1.8 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
pub enum GetItemsQueryString {
|
|
Folder,
|
|
Album,
|
|
Songs,
|
|
}
|
|
|
|
impl GetItemsQueryString {
|
|
pub fn build(&self, parent_id: impl Into<String> + std::fmt::Display) -> String {
|
|
let common = format!("parentId={parent_id}&enable_images=false");
|
|
match self {
|
|
Self::Folder => format!("{common}&SortBy=SortName&fields=Path,RecursiveItemCount"),
|
|
Self::Album => format!("{common}&SortBy=SortName&fields=Path,RecursiveItemCount"),
|
|
Self::Songs => format!(
|
|
"{common}&SortBy=ParentIndexNumber,IndexNumber,SortName&fields=ItemCounts,MediaSourceCount,Path"
|
|
),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub struct GetItemsResponseModel {
|
|
pub items: Vec<ItemModel>,
|
|
pub total_record_count: u64,
|
|
pub start_index: u64,
|
|
}
|
|
|
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub struct ItemModel {
|
|
pub name: String,
|
|
pub id: String,
|
|
pub path: String,
|
|
pub production_year: Option<i64>,
|
|
pub is_folder: bool,
|
|
#[serde(rename = "Type")]
|
|
pub type_field: String,
|
|
pub artists: Option<Vec<String>>,
|
|
pub artist_items: Option<Vec<ArtistItemModel>>,
|
|
pub album_artist: Option<String>,
|
|
pub album_artists: Option<Vec<AlbumArtistModel>>,
|
|
pub media_type: String,
|
|
#[serde(default)]
|
|
pub recursive_item_count: u64,
|
|
}
|
|
|
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub struct ArtistItemModel {
|
|
pub name: String,
|
|
pub id: String,
|
|
}
|
|
|
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub struct AlbumArtistModel {
|
|
pub name: String,
|
|
pub id: String,
|
|
}
|