search feature added
This commit is contained in:
@@ -136,6 +136,10 @@ impl JellyfinClient {
|
||||
req = req.query(&[("IncludeItemTypes", types)]);
|
||||
}
|
||||
|
||||
if let Some(term) = query.search_term.as_deref() {
|
||||
req = req.query(&[("SearchTerm", term)]);
|
||||
}
|
||||
|
||||
let resp = req.send().map_err(|e| format!("request failed: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
@@ -155,21 +159,29 @@ impl JellyfinClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// What kind of library list we want.
|
||||
#[derive(Clone)]
|
||||
pub struct LibraryQuery {
|
||||
pub include_item_types: Option<String>, // e.g. Some("Movie".into())
|
||||
pub include_item_types: Option<String>,
|
||||
pub search_term: Option<String>,
|
||||
}
|
||||
|
||||
impl LibraryQuery {
|
||||
pub fn movies() -> Self {
|
||||
Self { include_item_types: Some("Movie".into()) }
|
||||
Self { include_item_types: Some("Movie".into()), search_term: None }
|
||||
}
|
||||
pub fn shows() -> Self {
|
||||
Self { include_item_types: Some("Series".into()) }
|
||||
Self { include_item_types: Some("Series".into()), search_term: None }
|
||||
}
|
||||
pub fn music() -> Self {
|
||||
Self { include_item_types: Some("Audio".into()) }
|
||||
Self { include_item_types: Some("Audio".into()), search_term: None }
|
||||
}
|
||||
pub fn all() -> Self {
|
||||
Self { include_item_types: None, search_term: None }
|
||||
}
|
||||
|
||||
pub fn with_search(mut self, term: String) -> Self {
|
||||
self.search_term = Some(term);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user