~aleteoryx/lfm_embed

f548d2d297bbf452aa206042f2029d7137df0477 — alyx 8 months ago 95fe09d release-0.2.0
Various fixes
5 files changed, 9 insertions(+), 6 deletions(-)

M README.md
M src/cache/user.rs
M src/ctx.rs
M src/deserialize.rs
M src/theming/hbs/plain.hbs
M README.md => README.md +4 -1
@@ 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.


M src/cache/user.rs => src/cache/user.rs +1 -1
@@ 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::<GetTrackInfo>(&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;


M src/ctx.rs => src/ctx.rs +2 -2
@@ 53,7 53,7 @@ pub mod model {
    /// The name of the track.
    pub name: Arc<str>,
    /// The name of its album.
    pub album: Arc<str>,
    pub album: Option<Arc<str>>,
    /// The artist who made it.
    pub artist: Artist,



@@ 126,7 126,7 @@ pub async fn get_ctx(api_result: Result<UserInfo, (StatusCode, &'static str)>, 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()),

M src/deserialize.rs => src/deserialize.rs +1 -1
@@ 106,7 106,7 @@ pub struct Track {
  #[serde(default)]
  pub images: Vec<Image>,
  pub mbid: Option<Arc<str>>,
  pub album: Album,
  pub album: Option<Album>,
  pub name: Arc<str>,
  pub url: Arc<str>,
  #[serde(deserialize_with = "str_num")]

M src/theming/hbs/plain.hbs => src/theming/hbs/plain.hbs +1 -1
@@ 1,5 1,5 @@
<!doctype html>
<html lang="en" style="margin: 20px; overflow: hidden;">
<html lang="en" style="margin: 4px; overflow: hidden;">
  <head>
    <meta charset="UTF-8"/>
    <title>{{#if error}}Error!{{else}}@{{user.name}}'s Last.fm Stats{{/if}}</title>