A beautiful Streamlit app that creates personalized playlists based on your current mood! Features both a demo mode for instant playlists and full Spotify integration for real playlists.
- π 4 Mood Options: Happy, Sad, Energetic, Chill
- π― Demo Mode: Instant playlists with sample tracks (no setup required)
- π Spotify Integration: Create real playlists in your Spotify account
- π¨ Beautiful UI: Modern, responsive design with custom styling
- π Real-time Stats: Track your playlist creation history
- π― Mood Guide: Learn about each mood and its characteristics
git clone https://github.com/codingnoodle/mood_playlist.git
cd mood_playlistOn macOS/Linux:
# Create virtual environment
python3 -m venv mood_playlist_env
# Activate virtual environment
source mood_playlist_env/bin/activateOn Windows:
# Create virtual environment
python -m venv mood_playlist_env
# Activate virtual environment
mood_playlist_env\Scripts\activatepip install -r requirements.txt-
Run the App:
streamlit run app.py
-
Use Demo Mode:
- Choose your mood
- Click "Generate Demo Playlist"
- Get instant playlists with sample tracks!
-
Set Up Spotify API:
- Go to Spotify Developer Dashboard
- Create a new app
- Add
http://127.0.0.1:8504to Redirect URIs
-
Configure Environment:
# Copy the example file cp env_example.txt .env # Edit .env with your credentials SPOTIFY_CLIENT_ID=your_client_id_here SPOTIFY_CLIENT_SECRET=your_client_secret_here SPOTIFY_REDIRECT_URI=http://127.0.0.1:8504
-
Run the App:
streamlit run app.py
-
Create Real Playlists:
- Choose your mood
- Click "Create Real Spotify Playlist"
- Authenticate with Spotify
- Get real playlists in your account!
- No Authentication Required: Works instantly
- Sample Tracks: Curated tracks for each mood
- Spotify Links: Direct links to real Spotify tracks
- Instant Results: No waiting or setup
- Real Playlists: Creates actual playlists in your Spotify account
- Smart Search: Searches Spotify for mood-appropriate tracks
- Direct Integration: Adds tracks directly to your account
- Public Playlists: Share with friends!
| Mood | Genres | Description |
|---|---|---|
| Happy | Pop, Dance, Electronic | Upbeat and energetic tracks |
| Sad | Indie, Folk, Acoustic | Gentle and soothing tracks |
| Energetic | Rock, Metal, Electronic | High-energy pump-up tracks |
| Chill | Chill, Ambient, Jazz | Relaxing laid-back vibes |
mood_playlist/
βββ app.py # Main application
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ env_example.txt # Environment template
βββ .streamlit/ # Streamlit configuration
β βββ config.toml
βββ mood_playlist_env/ # Virtual environment
- Frontend: Streamlit (Python web framework)
- Music API: Spotify Web API via Spotipy
- Authentication: OAuth 2.0 with Spotify
- Styling: Custom CSS with modern design
- Data Processing: Pandas, NumPy
-
Push to GitHub:
git add . git commit -m "Initial commit" git push origin main
-
Deploy on Streamlit Cloud:
- Go to share.streamlit.io
- Connect your GitHub account
- Select your repository
- Add your environment variables in the settings
- Deploy!
- Heroku: Use the
requirements.txtand set environment variables - Railway: Connect GitHub repo and add environment variables
- Vercel: Deploy with Python runtime
| Variable | Description | Required |
|---|---|---|
SPOTIFY_CLIENT_ID |
Your Spotify App Client ID | For real playlists |
SPOTIFY_CLIENT_SECRET |
Your Spotify App Client Secret | For real playlists |
SPOTIFY_REDIRECT_URI |
OAuth redirect URI | For real playlists |
- Choose Mood: Select how you're feeling
- Generate Demo: Click "Generate Demo Playlist"
- Enjoy: View sample tracks with Spotify links
- Choose Mood: Select how you're feeling
- Authenticate: Click "Create Real Spotify Playlist"
- Login: Complete Spotify authentication
- Enjoy: Open the playlist in Spotify
Edit the MOOD_GENRES dictionary in app.py:
"New Mood": {
"genres": ["genre1", "genre2"],
"description": "Your mood description",
"color": "#HEXCODE"
}Edit the DEMO_TRACKS dictionary in app.py:
"New Mood": [
{"name": "Song Name", "artist": "Artist Name", "url": "spotify_url"},
# Add more tracks...
]- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License.
- Spotify Web API for music data
- Streamlit for the web framework
- Spotipy for Spotify API wrapper
- App not loading: Check if Streamlit is installed correctly
- No playlists showing: Refresh the page and try again
- "Spotify credentials not found": Make sure you've created a
.envfile - "Authentication error": Check your Client ID and Secret
- "Invalid redirect URI": Ensure redirect URI matches your Spotify app settings
- "No tracks found": Try a different mood or check internet connection
- Port conflicts: Try running on a different port:
streamlit run app.py --server.port 8505 - Dependencies: Make sure all packages are installed:
pip install -r requirements.txt - Virtual environment: Ensure you're in the correct virtual environment before installing dependencies
Made with β€οΈ and π΅ for music lovers everywhere!