v0.1.10
build / test (push) Waiting to run

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-16 22:48:34 +01:00
1 parent 052a27bc48
commit 528017b0e6
36 files changed
+3394 -216

No files matched your search

+21 -1
View File
@@ -28,6 +28,10 @@ pub struct StreamQuery {
share: Option<String>,
profile: Option<String>,
format: Option<String>,
/// M3U: only these channels (comma separated channel ids, e.g. the favourites)
channels: Option<String>,
/// M3U: only this channel group
group: Option<String>,
}
impl StreamQuery {
@@ -123,10 +127,26 @@ pub async fn playlist(
Ok(p) => p,
Err(e) => return e.into_response(),
};
let channels = match state.db.channels().await {
let mut channels = match state.db.channels().await {
Ok(c) => c,
Err(e) => return ApiError::from(e).into_response(),
};
if let Some(ids) = q.channels.as_deref().filter(|s| !s.is_empty()) {
// keeps the given order (e.g. favourites in the order they were added)
let ids: Vec<i64> = ids
.split(',')
.filter_map(|x| x.trim().parse().ok())
.collect();
let mut picked: Vec<crate::db::Channel> = ids
.iter()
.filter_map(|id| channels.iter().find(|c| c.id == *id).cloned())
.collect();
picked.sort_by_key(|c| ids.iter().position(|i| *i == c.id));
channels = picked;
}
if let Some(g) = q.group.as_deref().filter(|s| !s.is_empty()) {
channels.retain(|c| c.grp == g);
}
let auth_q = ctx.access.query();
let body = crate::m3u::build(
&channels,