This is a Cloudflare Worker script that fetches the recently played / now playing track from a Last.fm user and displays it as an HTML page.
You can see a demo of this script in action here.
To set up the script, follow these steps:
-
Clone this repository:
git clone https://github.com/petitstrawberry/lastfm-api-worker.git cd lastfm-api-worker
-
Configuration:
Edit
src/config.ts
and set your Last.fm API key and your username.export const config = { API_KEY: "YOUR_API_KEY", USERNAME: "YOUR_USERNAME" }
-
Build:
Install dependencies:
npm install
Check if it is working:
wrangler dev
-
Deployment:
wrangler deploy
This will deploy the script to Cloudflare Workers.