Added better artist bio/pics/lyrics

This commit is contained in:
Connor Johnstone
2026-03-19 14:53:39 -04:00
parent f6b363c40f
commit 51bcf26482
9 changed files with 580 additions and 23 deletions

View File

@@ -98,6 +98,11 @@ pub async fn delete_user(id: i32) -> Result<(), ApiError> {
delete(&format!("{BASE}/auth/users/{id}")).await
}
// --- Lyrics ---
pub async fn get_lyrics(artist: &str, title: &str) -> Result<LyricsResult, ApiError> {
get_json(&format!("{BASE}/lyrics?artist={artist}&title={title}")).await
}
// --- Status ---
pub async fn get_status() -> Result<Status, ApiError> {
get_json(&format!("{BASE}/status")).await
@@ -108,7 +113,11 @@ pub async fn search_artist(query: &str, limit: u32) -> Result<Vec<ArtistResult>,
get_json(&format!("{BASE}/search/artist?q={query}&limit={limit}")).await
}
pub async fn search_album(query: &str, artist: Option<&str>, limit: u32) -> Result<Vec<AlbumResult>, ApiError> {
pub async fn search_album(
query: &str,
artist: Option<&str>,
limit: u32,
) -> Result<Vec<AlbumResult>, ApiError> {
let mut url = format!("{BASE}/search/album?q={query}&limit={limit}");
if let Some(a) = artist {
url.push_str(&format!("&artist={a}"));
@@ -116,7 +125,11 @@ pub async fn search_album(query: &str, artist: Option<&str>, limit: u32) -> Resu
get_json(&url).await
}
pub async fn search_track(query: &str, artist: Option<&str>, limit: u32) -> Result<Vec<TrackResult>, ApiError> {
pub async fn search_track(
query: &str,
artist: Option<&str>,
limit: u32,
) -> Result<Vec<TrackResult>, ApiError> {
let mut url = format!("{BASE}/search/track?q={query}&limit={limit}");
if let Some(a) = artist {
url.push_str(&format!("&artist={a}"));
@@ -158,7 +171,11 @@ pub async fn add_artist(name: &str, mbid: Option<&str>) -> Result<AddSummary, Ap
post_json(&format!("{BASE}/artists"), &body).await
}
pub async fn add_album(artist: &str, album: &str, mbid: Option<&str>) -> Result<AddSummary, ApiError> {
pub async fn add_album(
artist: &str,
album: &str,
mbid: Option<&str>,
) -> Result<AddSummary, ApiError> {
let body = match mbid {
Some(m) => format!(r#"{{"artist":"{artist}","album":"{album}","mbid":"{m}"}}"#),
None => format!(r#"{{"artist":"{artist}","album":"{album}"}}"#),