Added the playlist generator

This commit is contained in:
Connor Johnstone
2026-03-20 18:09:47 -04:00
parent 9d6c0e31c1
commit ea6a6410f3
17 changed files with 962 additions and 116 deletions

View File

@@ -227,6 +227,15 @@ pub async fn trigger_monitor_check() -> Result<TaskRef, ApiError> {
post_empty(&format!("{BASE}/monitor/check")).await
}
// --- Scheduler ---
pub async fn skip_scheduled_pipeline() -> Result<serde_json::Value, ApiError> {
post_empty(&format!("{BASE}/scheduler/skip-pipeline")).await
}
pub async fn skip_scheduled_monitor() -> Result<serde_json::Value, ApiError> {
post_empty(&format!("{BASE}/scheduler/skip-monitor")).await
}
// --- System ---
pub async fn trigger_index() -> Result<TaskRef, ApiError> {
post_empty(&format!("{BASE}/index")).await
@@ -259,6 +268,42 @@ pub async fn save_config(config: &AppConfig) -> Result<AppConfig, ApiError> {
resp.json().await.map_err(|e| ApiError(e.to_string()))
}
// --- Playlists ---
pub async fn generate_playlist(req: &GenerateRequest) -> Result<GeneratedPlaylist, ApiError> {
let body = serde_json::to_string(req).map_err(|e| ApiError(e.to_string()))?;
post_json(&format!("{BASE}/playlists/generate"), &body).await
}
pub async fn save_playlist(
name: &str,
description: Option<&str>,
track_ids: &[i32],
) -> Result<serde_json::Value, ApiError> {
let body = serde_json::json!({
"name": name,
"description": description,
"track_ids": track_ids,
})
.to_string();
post_json(&format!("{BASE}/playlists"), &body).await
}
pub async fn list_playlists() -> Result<Vec<PlaylistSummary>, ApiError> {
get_json(&format!("{BASE}/playlists")).await
}
pub async fn get_playlist(id: i32) -> Result<PlaylistDetail, ApiError> {
get_json(&format!("{BASE}/playlists/{id}")).await
}
pub async fn delete_playlist(id: i32) -> Result<(), ApiError> {
delete(&format!("{BASE}/playlists/{id}")).await
}
pub fn export_m3u_url(id: i32) -> String {
format!("{BASE}/playlists/{id}/m3u")
}
// --- YouTube Auth ---
pub async fn get_ytauth_status() -> Result<YtAuthStatus, ApiError> {