feat(library): focused music/TV/movie landing screens + self-draining download queue
Library screens:
- Add dedicated music, TV, and movie landing pages (hero banner +
horizontal carousels) backed by new music/tv/movies stores.
- Route tvshows libraries to /library/tv; surface rediscover ("haven't
listened to in a while") albums via a new repository method across
online/offline/hybrid repos plus the repository_get_rediscover_albums
command.
- Add an A-Z jump bar for long alphabetically-sorted lists, with grid
index anchors in LibraryGrid/LibraryListView/TrackList.
- Filter the "Podcasts" folder out of music library queries.
Downloads:
- Add a backend queue pump: enqueue_download / enqueue_video_downloads
persist the resolved stream URL + target dir on each row (migration
017), and the pump starts up to max_concurrent and drains the rest
automatically as slots free, instead of the frontend silently dropping
items past the concurrency limit. Album/series/season buttons now
enqueue rather than calling start_download directly.
Other fixes:
- Hybrid search now returns instant cache results and pushes the merged
cache+server union via a request-id-tagged search-event, so superseded
queries can't clobber fresher results.
- URL-encode SearchTerm / genres / item types in online repo requests.
- Android: pause on audio-becoming-noisy (headphone/BT disconnect).
This commit is contained in:
@@ -568,6 +568,16 @@ impl MediaRepository for OnlineRepository {
|
||||
if let Some(recursive) = opts.recursive {
|
||||
endpoint.push_str(&format!("&Recursive={}", recursive));
|
||||
}
|
||||
if let Some(genres) = opts.genres {
|
||||
if !genres.is_empty() {
|
||||
// Genre names may contain spaces/ampersands, so percent-encode each.
|
||||
let encoded: Vec<String> = genres
|
||||
.iter()
|
||||
.map(|g| urlencoding::encode(g).into_owned())
|
||||
.collect();
|
||||
endpoint.push_str(&format!("&Genres={}", encoded.join("|")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Request image fields for list views (People only needed in get_item detail view)
|
||||
@@ -759,6 +769,32 @@ impl MediaRepository for OnlineRepository {
|
||||
Ok(final_result)
|
||||
}
|
||||
|
||||
async fn get_rediscover_albums(
|
||||
&self,
|
||||
parent_id: Option<&str>,
|
||||
limit: Option<usize>,
|
||||
) -> Result<Vec<MediaItem>, RepoError> {
|
||||
let limit_val = limit.unwrap_or(12);
|
||||
// Ask Jellyfin for played albums sorted by least-recently played first.
|
||||
// Filters=IsPlayed keeps only albums the user has actually listened to,
|
||||
// and SortBy=DatePlayed ascending surfaces the ones they've neglected.
|
||||
let mut endpoint = format!(
|
||||
"/Users/{}/Items?SortBy=DatePlayed&SortOrder=Ascending&IncludeItemTypes=MusicAlbum&Limit={}&Recursive=true&Filters=IsPlayed&Fields=BackdropImageTags,ParentBackdropImageTags",
|
||||
self.user_id, limit_val
|
||||
);
|
||||
|
||||
if let Some(pid) = parent_id {
|
||||
endpoint.push_str(&format!("&ParentId={}", pid));
|
||||
}
|
||||
|
||||
let response: ItemsResponse = self.get_json(&endpoint).await?;
|
||||
Ok(response
|
||||
.items
|
||||
.into_iter()
|
||||
.map(|item| item.to_media_item(self.user_id.clone()))
|
||||
.collect())
|
||||
}
|
||||
|
||||
async fn get_resume_movies(&self, limit: Option<usize>) -> Result<Vec<MediaItem>, RepoError> {
|
||||
let limit_str = limit.unwrap_or(16);
|
||||
let endpoint = format!(
|
||||
@@ -811,14 +847,24 @@ impl MediaRepository for OnlineRepository {
|
||||
options: Option<SearchOptions>,
|
||||
) -> Result<SearchResult, RepoError> {
|
||||
let limit = options.as_ref().and_then(|o| o.limit).unwrap_or(50);
|
||||
// SearchTerm is arbitrary user input and must be percent-encoded so that
|
||||
// spaces, ampersands, etc. don't corrupt the query string (a multi-word
|
||||
// search like "Star Wars" would otherwise produce a malformed URL).
|
||||
let mut endpoint = format!(
|
||||
"/Users/{}/Items?SearchTerm={}&Limit={}&Recursive=true",
|
||||
self.user_id, query, limit
|
||||
self.user_id,
|
||||
urlencoding::encode(query),
|
||||
limit
|
||||
);
|
||||
|
||||
if let Some(opts) = options {
|
||||
if let Some(types) = opts.include_item_types {
|
||||
endpoint.push_str(&format!("&IncludeItemTypes={}", types.join(",")));
|
||||
let encoded_types = types
|
||||
.iter()
|
||||
.map(|t| urlencoding::encode(t).into_owned())
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
endpoint.push_str(&format!("&IncludeItemTypes={}", encoded_types));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1768,4 +1814,13 @@ mod tests {
|
||||
assert_eq!(response.items[0].id, "item1");
|
||||
assert_eq!(response.items[1].id, "item2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_term_is_url_encoded() {
|
||||
// A multi-word query (and one with a reserved character) must be
|
||||
// percent-encoded before being placed in the SearchTerm query param,
|
||||
// otherwise the request URL is malformed and search returns nothing.
|
||||
assert_eq!(urlencoding::encode("Star Wars"), "Star%20Wars");
|
||||
assert_eq!(urlencoding::encode("Tom & Jerry"), "Tom%20%26%20Jerry");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user