Skip to content

About

A lightweight Python web app to generate custom your music stats like "Spotify Wrapped"-style infographics using Last.fm, Spotify API, and Generative AI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🎵 Music Stats Wrap Generator

Python Flask Docker Open Source

A lightweight, open-source Python web application that generates highly customizable, "Spotify Wrapped"-style infographics based on your listening history. It seamlessly integrates with both Last.fm and Spotify API, utilizing Generative AI to accurately determine your music taste.


✨ Key Features

  • Dual Platform Support: Pull your weekly, monthly, or yearly listening stats seamlessly via Last.fm or Spotify API.
  • AI-Powered Vibe & Lyrics Extraction: Uses Google Gemini (with fallbacks to OpenRouter/Groq) to intelligently extract iconic lyrics from your top tracks and accurately determine your specific sub-genre/vibe.
  • Pixel-Perfect Image Rendering: Dynamically draws gorgeous, Figma-styled posters using Pillow, featuring auto-shrinking typography and full support for CJK (Chinese, Japanese, Korean) characters.
  • Highly Optimized for Low-End Servers: Designed to run flawlessly on 1GB RAM VPS. Uses Gunicorn + Gevent for asynchronous non-blocking workers and DBUtils for smart MySQL Connection Pooling.

⚙️ Tech Stack

  • Backend: Python, Flask, Spotipy, Gunicorn, Gevent
  • Image Processing: Pillow, Pilmoji
  • Database Management: MySQL (Production), SQLite (Local/Development)
  • AI Engine: Google Generative AI
  • Infrastructure: Docker & Docker Compose

🚀 Quick Start Guide

1. Clone the Repository

git clone https://github.com/kenthoeng/music-wrap.git
cd music-wrap

2. Environment Setup

Copy the configuration template and fill in your actual API keys.

cp .env.example .env
nano .env

(Make sure to obtain your API Keys from Last.fm, Spotify Developer Dashboard, and Google AI Studio).

3. Running via Docker (Production Recommended)

Ensure Docker and Docker Compose are installed on your machine/VPS, then simply run:

docker compose up -d --build

Check the application logs to ensure everything is running smoothly:

docker logs -f music_wrap_app

The app will be live at http://localhost:5000 (or your server's IP address).

4. Running Locally (Development Mode)

If you want to run it without Docker for local modification:

pip install -r requirements.txt
python app.py

⚠️ Important Note regarding Spotify API

Due to Spotify's updated Developer Policy (February 2026), third-party apps running in "Development Mode" are strictly limited to 5 users. The Spotify login feature will yield a 403 Forbidden error for unregistered users. To grant access, the developer must manually whitelist the user's Spotify email address in the Spotify Developer Dashboard.

For public usage, it is highly recommended to rely on the Last.fm integration as it has no user limitations.


🇮🇩 Terjemahan Bahasa Indonesia

Sebuah aplikasi web berbasis Python yang ringan dan open-source untuk menghasilkan infografis statistik musik ala "Spotify Wrapped". Terintegrasi dengan Last.fm dan Spotify API, serta memanfaatkan AI untuk menganalisis selera musikmu secara akurat.

✨ Fitur Utama

  • Dukungan Dua Platform: Tarik data statistik (mingguan, bulanan, tahunan) melalui Last.fm atau akun Spotify-mu.
  • Analisis Genre & Lirik via AI: Menggunakan Google Gemini (dengan cadangan OpenRouter/Groq) untuk mengekstrak potongan lirik paling ikonik dan menganalisis sub-genre musikmu.
  • Mesin Gambar Presisi Tinggi: Menggambar poster secara dinamis menggunakan Pillow yang dilengkapi dengan tipografi adaptif dan dukungan penuh huruf Asia (Jepang/Korea).
  • Sangat Ringan untuk Server Kecil: Dirancang khusus agar anti-crash di VPS dengan RAM 1GB menggunakan arsitektur Gunicorn + Gevent serta MySQL Connection Pooling.

🚀 Panduan Instalasi

1. Kloning Repositori

git clone https://github.com/kenthoeng/music-wrap.git
cd music-wrap

2. Konfigurasi Sistem Salin file templat rahasia dan masukkan API Key milikmu.

cp .env.example .env
nano .env

3. Jalankan dengan Docker (Rekomendasi Server) Jalankan perintah ini di terminal VPS/lokalmu:

docker compose up -d --build

Untuk memantau log aplikasi secara real-time:

docker logs -f music_wrap_app

Aplikasi bisa langsung diakses melalui http://localhost:5000.

⚠️ Catatan Penting API Spotify

Berdasarkan aturan baru Spotify Developer (Februari 2026), aplikasi dalam mode Development dibatasi maksimal hanya 5 pengguna. Pengguna yang tidak terdaftar akan mengalami error 403 Forbidden saat mencoba login. Agar bisa dipakai oleh temanmu, kamu harus mendaftarkan email akun Spotify mereka secara manual ke whitelist di Dashboard Spotify milikmu.

Untuk penggunaan bebas oleh publik, sangat disarankan menggunakan jalur input Last.fm.


👨‍💻 Built with ☕ and Open-Sourced by Hamnurz

Feel free to fork, modify, and contribute to this repository!

About

A lightweight Python web app to generate custom your music stats like "Spotify Wrapped"-style infographics using Last.fm, Spotify API, and Generative AI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages