From f548d2d297bbf452aa206042f2029d7137df0477 Mon Sep 17 00:00:00 2001 From: alyx Date: Mon, 8 Apr 2024 11:59:29 -0400 Subject: Various fixes --- README.md | 5 ++++- src/cache/user.rs | 2 +- src/ctx.rs | 4 ++-- src/deserialize.rs | 2 +- src/theming/hbs/plain.hbs | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 02c6c4a..5cb7b17 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,12 @@ The following are the environment variables which `lfm_embed` understands. ## Core Config -### `LMFE_API_KEY` (Required) +### `LMFE_LASTFM_API_KEY` (Required) Your last.fm API key. You'll need to create one [here](https://www.last.fm/api/account/create) for self-hosting. +### `LMFE_GOOGLE_API_KEY` +Your google API key. This is necessary for custom google fonts to work. You can create one [here](https://developers.google.com/fonts/docs/developer_api#APIKey), and you'll need some familiarity with the Google cloud API console + ### `LFME_PORT` (Default: `9999`) The port to serve on locally. diff --git a/src/cache/user.rs b/src/cache/user.rs index 8d6bf64..6d2d414 100644 --- a/src/cache/user.rs +++ b/src/cache/user.rs @@ -54,7 +54,7 @@ fn user_getter(username: &String) -> UserFuture { if trackreq.status() == StatusCode::NOT_FOUND { return Err((StatusCode::NOT_FOUND, "Track does not exist!")); } let trackstr = trackreq.text().await.unwrap(); - log::trace!("Got user.getTrackInfo JSON for `{username}`: {trackstr}"); + 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; diff --git a/src/ctx.rs b/src/ctx.rs index 3d14e4c..1b007ff 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -53,7 +53,7 @@ pub mod model { /// The name of the track. pub name: Arc, /// The name of its album. - pub album: Arc, + pub album: Option>, /// The artist who made it. pub artist: Artist, @@ -126,7 +126,7 @@ pub async fn get_ctx(api_result: Result, f }, scrobble: model::Scrobble { name: track.name.clone(), - album: track.album.title.clone(), + album: track.album.as_ref().map(|a| a.title.clone()), artist: model::Artist { name: track.artist.name.clone(), // image_url: track.artist.images.iter().max_by(|a, b| a.size.cmp(&b.size)).map(|a| a.url.clone()).unwrap_or_else(|| "".into()), diff --git a/src/deserialize.rs b/src/deserialize.rs index b1c4da8..0998cbd 100644 --- a/src/deserialize.rs +++ b/src/deserialize.rs @@ -106,7 +106,7 @@ pub struct Track { #[serde(default)] pub images: Vec, pub mbid: Option>, - pub album: Album, + pub album: Option, pub name: Arc, pub url: Arc, #[serde(deserialize_with = "str_num")] diff --git a/src/theming/hbs/plain.hbs b/src/theming/hbs/plain.hbs index b3c0abf..040a079 100644 --- a/src/theming/hbs/plain.hbs +++ b/src/theming/hbs/plain.hbs @@ -1,5 +1,5 @@ - + {{#if error}}Error!{{else}}@{{user.name}}'s Last.fm Stats{{/if}} -- cgit v1.2.3-70-g09d2