From 074c512ac422dbd86527b943b54e33200784b478 Mon Sep 17 00:00:00 2001 From: alyx Date: Tue, 9 Apr 2024 17:10:27 -0400 Subject: Fixed backend API, again. Turns out track.getInfo just doesn't feel like serving image data anymore, even though the example response shows it. I love last.fm so much. --- src/cache/user.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cache') diff --git a/src/cache/user.rs b/src/cache/user.rs index 6d2d414..b05d0d1 100644 --- a/src/cache/user.rs +++ b/src/cache/user.rs @@ -35,6 +35,7 @@ fn user_getter(username: &String) -> UserFuture { log::trace!("Got user.getUserInfo JSON for `{username}`: {userstr}"); let userinfo = serde_json::from_str::(&userstr) .map_err(|e| {log::error!("Couldn't parse user.getInfo for `{username}`: {e}"); (StatusCode::INTERNAL_SERVER_ERROR, "Couldn't parse user.getInfo!")})?.user; + log::trace!("Parsed into: {userinfo:?}"); let tracksreq = HTTP.get(format!("https://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&format=json&extended=1&limit=1&user={username}&api_key={}", CONFIG.lastfm_api_key)) .send().await @@ -47,6 +48,7 @@ fn user_getter(username: &String) -> UserFuture { let trackstub = serde_json::from_str::(&tracksstr) .map_err(|e| {log::error!("Couldn't parse user.getRecentTracks for `{username}`: {e}"); (StatusCode::INTERNAL_SERVER_ERROR, "Couldn't parse user.getRecentTracks!")})? .recenttracks.track.into_iter().next().ok_or((StatusCode::UNPROCESSABLE_ENTITY, "You need to listen to some songs first!"))?; + log::trace!("Parsed into: {trackstub:?}"); let trackreq = HTTP.get(format!("https://ws.audioscrobbler.com/2.0/?method=track.getInfo&format=json&username={username}&api_key={}&track={}&artist={}", CONFIG.lastfm_api_key, trackstub.name, trackstub.artist.name)) .send().await @@ -57,6 +59,7 @@ fn user_getter(username: &String) -> UserFuture { log::trace!("Got track.getInfo JSON for `{username}`: {trackstr}"); let trackinfo = serde_json::from_str::(&trackstr) .map_err(|e| {log::error!("Couldn't parse track.getInfo for `{}` by `{}` on behalf of {username}: {e}", trackstub.name, trackstub.artist.name); (StatusCode::INTERNAL_SERVER_ERROR, "Couldn't parse track.getInfo!")})?.track; + log::trace!("Parsed into: {trackinfo:?}"); Ok(Arc::new((userinfo, trackinfo, trackstub))) }) -- cgit v1.2.3-70-g09d2