Why PastFm • Features • Usage • Architecture • Local Development • Deployment • Contributing • License
I had been using the spotify-github-profile banner for a long time. But ever since Spotify restricted modded apps, I found myself using multiple music platforms. PastFm solves this by connecting to Last.fm which aggregates my listening activity across platforms!
Big thanks to kittinan whose design inspired PastFm's card theme.
- 🎵 Cross-platform support: Works with any music service that scrobbles to Last.fm
- 🎨 Customizable: Change colors and username parameters
- 🔄 Live updates: Shows currently playing or recently played tracks
- 🖼️ Album artwork: Displays album cover art when available
- 🚀 Fast rendering: Optimized SVG generation with minimal dependencies
-
Sign up for Last.fm and connect your music platforms (Spotify, Apple Music, YouTube Music, etc.)
-
Add the banner to your GitHub profile README:

-
Customize (optional):
- Change the color:
&color=f70000
(hex color without #) - Example with custom color:

- Change the color:
PastFm is built with a simple but effective architecture that enables real-time music status display from Last.fm on GitHub profiles.
flowchart TD
A[GitHub Profile] -->|Request Banner| B[FastAPI Server]
B -->|Request Playing Track| C[Last.fm API]
C -->|Return Track Data| B
B -->|Process Data| D[Generate Visualization]
D -->|Render SVG| E[Jinja2 Template]
E -->|Return Banner| A
subgraph "PastFm Backend"
B
D
E
end
style A fill:#f9f9f9,stroke:#333,stroke-width:2px
style B fill:#3498db,stroke:#333,stroke-width:2px,color:#fff
style C fill:#e74c3c,stroke:#333,stroke-width:2px,color:#fff
style D fill:#2ecc71,stroke:#333,stroke-width:2px,color:#fff
style E fill:#9b59b6,stroke:#333,stroke-width:2px,color:#fff
-
API Layer (
app/api.py
):- FastAPI routes handle requests for the Now Playing card
- Endpoints support customization (username, color)
- Cache control ensures up-to-date display
-
Last.fm Client (
utils/lastfm.py
):- Makes API calls to Last.fm to retrieve scrobble data
- Handles track metadata and image processing
- Error handling for API failures
-
Visualization Engine (
utils/visualization.py
):- Generates CSS animations for audio visualization bars
- Creates dynamic visual elements
-
Template Renderer (
templates/default_theme.html
):- Jinja2 template for SVG image generation
- Responsive design with customizable styling
-
Configuration (
config.py
):- Centralized settings with environment variable support
- Default parameters for customization
-
Clone the repository:
git clone https://github.com/arpy8/PastFm.git cd PastFm
-
Set up a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
- Copy
.env.example
to.env
- Add your Last.fm API key (get one from Last.fm API)
- Copy
-
Add a placeholder image:
- Create a
temp.gif
file in thestatic/
directory for fallback album art
- Create a
-
Run the application:
python main.py
-
Test the application:
- Open
http://localhost:7860/live?user=YOUR_LASTFM_USERNAME
in your browser
- Open
PastFm is designed to be deployed easily to platforms like Hugging Face Spaces or similar services:
-
Using Docker:
docker build -t pastfm . docker run -p 7860:7860 -e LASTFM_API_KEY=YOUR_KEY pastfm
-
On Hugging Face Spaces:
- Create a new Space with Docker template
- Add your Last.fm API key as a secret
- Push the code to the Space repository
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Created by arpy8 | Report Bug