From d441079dcf849fa16d22c91a9b75a8bcb1a98384 Mon Sep 17 00:00:00 2001 From: weightedangelcube Date: Fri, 23 May 2025 22:51:39 -0600 Subject: [PATCH] feat: last played song from last.fm --- .github/workflows/deploy.yml | 2 ++ src/pages/index.astro | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7ec5434..aea55db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,6 +17,8 @@ permissions: jobs: build: runs-on: ubuntu-latest + env: + LASTFM_KEY: ${{ secrets.LASTFM_KEY }} steps: - name: checkout uses: actions/checkout@v4 diff --git a/src/pages/index.astro b/src/pages/index.astro index 3684588..cf0eb70 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,6 +1,12 @@ --- import Layout from "../layouts/layout.astro"; import "../styles/main.scss"; + +const request = await fetch("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=angelcube__&api_key=" + import.meta.env.LASTFM_KEY + "&limit=1&format=json"); +const response = await request.json().then(data => data.recenttracks.track[0]); +const artist = response.artist["#text"]; +const name = response.name; +const album = response.album["#text"]; --- @@ -16,6 +22,9 @@ import "../styles/main.scss";

beyond coding, I love to sing, do a little drawing, and obsess over video games—currently, I'm plagued by my love of Celeste.

+ + last played song: {name} by {artist} on {album} +
-- 2.51.2