implimented first itteration of drill down
This commit is contained in:
@@ -123,7 +123,7 @@ impl JellyfinClient {
|
||||
.get(url)
|
||||
.header("X-Emby-Authorization", self.auth_header_value())
|
||||
.query(&[
|
||||
("Recursive", "true"),
|
||||
("Recursive", if query.recursive { "true" } else { "false" }),
|
||||
("StartIndex", &start_index.to_string()),
|
||||
("Limit", &limit.to_string()),
|
||||
("Fields", "PrimaryImageAspectRatio,SortName,ProductionYear"),
|
||||
@@ -131,6 +131,17 @@ impl JellyfinClient {
|
||||
("SortOrder", "Ascending"),
|
||||
]);
|
||||
|
||||
if let Some(types) = query.include_item_types.as_deref() {
|
||||
req = req.query(&[("IncludeItemTypes", types)]);
|
||||
}
|
||||
if let Some(parent) = query.parent_id.as_deref() {
|
||||
req = req.query(&[("ParentId", parent)]);
|
||||
}
|
||||
if let Some(term) = query.search_term.as_deref() {
|
||||
req = req.query(&[("SearchTerm", term)]);
|
||||
}
|
||||
|
||||
|
||||
// apply query (movie/series/etc)
|
||||
if let Some(types) = query.include_item_types.as_deref() {
|
||||
req = req.query(&[("IncludeItemTypes", types)]);
|
||||
@@ -159,32 +170,69 @@ impl JellyfinClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// What kind of library list we want.
|
||||
#[derive(Clone)]
|
||||
pub struct LibraryQuery {
|
||||
pub include_item_types: Option<String>,
|
||||
pub search_term: Option<String>,
|
||||
pub include_item_types: Option<String>, // e.g. Some("Movie".into())
|
||||
pub parent_id: Option<String>, // e.g. Some(series_id)
|
||||
pub search_term: Option<String>, // e.g. Some("matrix".into())
|
||||
pub recursive: bool, // true for big lists, false for drilldown
|
||||
}
|
||||
|
||||
impl LibraryQuery {
|
||||
pub fn movies() -> Self {
|
||||
Self { include_item_types: Some("Movie".into()), search_term: None }
|
||||
Self {
|
||||
include_item_types: Some("Movie".into()),
|
||||
parent_id: None,
|
||||
search_term: None,
|
||||
recursive: true,
|
||||
}
|
||||
}
|
||||
pub fn shows() -> Self {
|
||||
Self { include_item_types: Some("Series".into()), search_term: None }
|
||||
Self {
|
||||
include_item_types: Some("Series".into()),
|
||||
parent_id: None,
|
||||
search_term: None,
|
||||
recursive: true,
|
||||
}
|
||||
}
|
||||
pub fn music() -> Self {
|
||||
Self { include_item_types: Some("Audio".into()), search_term: None }
|
||||
}
|
||||
pub fn all() -> Self {
|
||||
Self { include_item_types: None, search_term: None }
|
||||
Self {
|
||||
include_item_types: Some("Audio".into()),
|
||||
parent_id: None,
|
||||
search_term: None,
|
||||
recursive: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_search(mut self, term: String) -> Self {
|
||||
self.search_term = Some(term);
|
||||
// true "All" (no filter)
|
||||
pub fn all() -> Self {
|
||||
Self {
|
||||
include_item_types: None,
|
||||
parent_id: None,
|
||||
search_term: None,
|
||||
recursive: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_parent(mut self, parent_id: impl Into<String>) -> Self {
|
||||
self.parent_id = Some(parent_id.into());
|
||||
self.recursive = false; // drilldown is usually direct children
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_search(mut self, term: impl Into<String>) -> Self {
|
||||
self.search_term = Some(term.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_item_types(mut self, types: impl Into<String>) -> Self {
|
||||
self.include_item_types = Some(types.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub struct PagedItems {
|
||||
pub items: Vec<JfItem>,
|
||||
pub total: usize,
|
||||
|
||||
Reference in New Issue
Block a user