feat: get songs from jellyfin

This commit is contained in:
Alexander Navarro 2025-10-18 19:31:45 -03:00
parent 49cf01c668
commit 12ad788452
7 changed files with 131 additions and 18 deletions

View file

@ -1,12 +1,22 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetItemsQueryStringModel {
pub parent_id: String,
pub sort_by: String,
pub fields: String,
pub enable_images: bool,
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)]
@ -32,6 +42,7 @@ pub struct ItemModel {
pub album_artist: Option<String>,
pub album_artists: Option<Vec<AlbumArtistModel>>,
pub media_type: String,
#[serde(default)]
pub recursive_item_count: u64,
}