Features β’ Demo β’ Installation β’ Usage β’ API β’ Contributing
- Overview
- Features
- Demo
- Architecture
- Installation
- Configuration
- Usage
- API Reference
- Project Structure
- Technologies Used
- Troubleshooting
- Contributing
- Roadmap
- License
- Acknowledgments
- Contact
Spotify Playlist Extractor is a powerful Flask web application that leverages Optical Character Recognition (OCR) to extract song titles and artist names from screenshots of Spotify playlists. It automatically searches for these songs on Spotify and creates a playlist for youβno manual typing required!
Now featuring a stunning dark mode UI inspired by Spotify's own design, making the experience seamless and beautiful.
Perfect for:
- π± Transferring playlists from screenshots
- π§ Recreating playlists shared as images
- π Backing up playlists from inaccessible accounts
- π Converting playlist recommendations from social media
|
|
|
|
graph LR
A[User Upload] --> B[Image Preprocessing]
B --> C[OCR Extraction]
C --> D[Text Parsing]
D --> E[Spotify Search]
E --> F[Playlist Creation]
F --> G[Success/Results]
style A fill:#e1f5ff
style G fill:#c8e6c9
- Image Upload: User uploads screenshots (PNG, JPG, JPEG)
- Preprocessing: Images are enhanced for better OCR accuracy
- Text Extraction: Tesseract OCR extracts text using multiple methods
- Smart Parsing: Algorithm identifies song-artist pairs
- Spotify Matching: Searches Spotify with multiple strategies
- Playlist Creation: Generates a new playlist with matched songs
Before you begin, ensure you have the following installed:
- Python 3.7+ - Download Python
- Tesseract OCR - Required for text extraction
- Spotify Account - Free or Premium
- ngrok (for development) - Download ngrok
Windows
- Download the installer from GitHub
- Run the installer (default path:
C:\Program Files\Tesseract-OCR) - Add Tesseract to your PATH or update the path in
.env
macOS
brew install tesseractLinux (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install tesseract-ocrgit clone https://github.com/CODEMASTERSTACK/Spotify-Extractor.git
cd spotify-playlist-extractor# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activatepip install -r requirements.txtrequirements.txt:
Flask>=2.0.0
Pillow>=9.0.0
pytesseract>=0.3.10
spotipy>=2.23.0
python-dotenv>=0.19.0- Go to Spotify Developer Dashboard
- Click "Create App"
- Fill in the details:
- App Name: Your app name
- App Description: Brief description
- Redirect URI:
http://localhost:5000/callback(or your ngrok URL)
- Accept terms and click "Create"
- Note your Client ID and Client Secret
Create a .env file in the project root (you can copy .env.example if available):
# Spotify Configuration
SPOTIPY_CLIENT_ID=your_client_id_here
SPOTIPY_CLIENT_SECRET=your_client_secret_here
SPOTIPY_REDIRECT_URI=http://localhost:5000/callback
# Flask Configuration
FLASK_SECRET_KEY=generate_a_strong_random_key_here
# Optional: Tesseract Path (if not in PATH)
# TESSERACT_CMD=C:\Program Files\Tesseract-OCR\tesseract.exeIf you want to test with a public URL:
ngrok http 5000Update SPOTIPY_REDIRECT_URI in your .env with the ngrok URL.
# Activate virtual environment
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Run the application
python app.pyThe application will be available at http://localhost:5000
- Open
http://localhost:5000in your browser - Click "Login with Spotify"
- Authorize the application
- Drag and drop your screenshots into the upload zone
- Select up to 10 images (PNG, JPG, JPEG)
- Click "Extract Songs"
Tips for Best Results:
- Use high-resolution screenshots
- Ensure text is clearly visible
- Avoid excessive UI elements in frame
- Crop to playlist area if possible
- View all extracted songs with album artwork
- Check the "Not Found" section for unmatched songs
- Use manual search for missing tracks
- Click "Add All to Playlist" to create a new playlist
- Or add songs individually with "Add" button
- Preview songs with the play button (if available)
- Open Spotify (mobile or desktop)
- Go to "Your Library"
- Find playlist named "Extracted Playlist [RANDOM]"
Upload and process images
Request:
- Method:
POST - Content-Type:
multipart/form-data - Body:
images(file array, max 10 files)
Initiate Spotify OAuth flow
Spotify OAuth callback
Add individual song to playlist
Request:
{
"track_uri": "spotify:track:xxx"
}Add all songs to playlist
Manual search for songs
Request:
{
"query": "search term"
}spotify-playlist-extractor/
β
βββ π app.py # Main Flask application
βββ π requirements.txt # Python dependencies
βββ π .env # Environment variables (create this!)
βββ π .gitignore # Git ignore rules
βββ π README.md # This file
β
βββ π templates/
β βββ π upload.html # Upload page (Drag & Drop)
β βββ π songs.html # Songs review page
β
βββ π static/
β βββ π css/
β β βββ π style.css # New Dark Theme Styles
β βββ π images/
β
βββ π uploads/ # Temporary upload directory
- Flask - Web framework
- Pytesseract - OCR wrapper for Tesseract
- Pillow (PIL) - Image processing
- Spotipy - Spotify API wrapper
- Python-Dotenv - Configuration management
- HTML5/CSS3 - Modern semantic markup
- Glassmorphism - Premium UI design
- JavaScript - Interactive elements
- Tesseract OCR - Text recognition engine
- PIL ImageEnhance - Contrast & sharpness enhancement
β Tesseract not found error
Error: pytesseract.pytesseract.TesseractNotFoundError
Solution:
- Verify Tesseract is installed:
tesseract --version - Update
TESSERACT_CMDin your.envfile:TESSERACT_CMD=C:\Program Files\Tesseract-OCR\tesseract.exe
β Spotify authentication fails
Error: Invalid redirect URI or Invalid client
Solution:
- Verify Client ID and Secret in
.env - Check redirect URI matches exactly in Spotify Dashboard
- Ensure ngrok is running and URL is up-to-date (if using ngrok)
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
- Support for Apple Music screenshots
- Playlist editing features
- Export to CSV/JSON
- Desktop application (Electron)
- Mobile app (React Native)
- Collaborative playlist creation
- Multiple image upload
- Advanced OCR processing
- Spotify integration
- Dark mode theme (UI Overhaul)
- Environment variable configuration
This project is licensed under the MIT License - see the LICENSE file for details.
- Tesseract OCR - Open source OCR engine
- Spotipy - Lightweight Python library for Spotify Web API
- Flask - Micro web framework
Kripal Singh
- GitHub: @CODEMASTERSTACK
- Email: leosen.krish@gmail.com
Project Link: https://github.com/CODEMASTERSTACK/spotify-Extractor
