V1 mpv playback

This commit is contained in:
2026-02-14 04:05:03 -06:00
parent 2dfbc7bbad
commit 5144af1cfb
2 changed files with 231 additions and 100 deletions
+22 -4
View File
@@ -118,21 +118,34 @@ impl JellyfinClient {
) -> Result<PagedItems, String> {
let url = format!("{}/Users/{}/Items", self.base_url, user_id);
let mut sort_by = "SortName";
if let Some(types) = query.include_item_types.as_deref() {
if types.contains("Episode") {
sort_by = "ParentIndexNumber,IndexNumber,SortName";
} else if types.contains("Audio") {
sort_by = "IndexNumber,SortName";
}
}
let mut req = self
.client
.get(url)
.header("X-Emby-Authorization", self.auth_header_value())
.query(&[
("Recursive", if query.recursive { "true" } else { "false" }),
("Recursive", "true"),
("StartIndex", &start_index.to_string()),
("Limit", &limit.to_string()),
("Fields", "PrimaryImageAspectRatio,SortName,ProductionYear"),
("SortBy", "SortName"),
("Fields", "PrimaryImageAspectRatio,SortName,ProductionYear,IndexNumber,ParentIndexNumber"),
("SortBy", sort_by),
("SortOrder", "Ascending"),
]);
if let Some(types) = query.include_item_types.as_deref() {
req = req.query(&[("IncludeItemTypes", types)]);
// Jellyfin expects IncludeItemTypes as repeated query params, not CSV
for t in types.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()) {
req = req.query(&[("IncludeItemTypes", t)]);
}
}
if let Some(parent) = query.parent_id.as_deref() {
req = req.query(&[("ParentId", parent)]);
@@ -248,6 +261,11 @@ pub struct JfItem {
pub item_type: Option<String>,
#[serde(rename = "ProductionYear")]
pub production_year: Option<i32>,
#[serde(rename = "IndexNumber")]
pub index_number: Option<i32>, // track # OR episode #
#[serde(rename = "ParentIndexNumber")]
pub parent_index_number: Option<i32>, // season # (for episodes)
}
#[derive(Deserialize)]