A Go program that extracts music playlists from a Plex Media Server SQLite database and exports them to M3U format files.
- Extract individual playlists by ID or all playlists at once
- Generate standard M3U format files with track metadata
- List all available playlists in the database
- Handle file path sanitization for cross-platform compatibility
- Support for playlist descriptions and metadata
- Make sure you have Go 1.21 or later installed
- Clone or download this repository
- Install dependencies:
go mod tidy
- Build the program:
go build -o plex-playlist-extractor
# List all available playlists
./plex-playlist-extractor -db /path/to/com.plexapp.plugins.library.db -list
# Extract all playlists
./plex-playlist-extractor -db /path/to/com.plexapp.plugins.library.db
# Extract a specific playlist by ID
./plex-playlist-extractor -db /path/to/com.plexapp.plugins.library.db -id 12502
# Specify custom output directory
./plex-playlist-extractor -db /path/to/com.plexapp.plugins.library.db -output ./my-playlists-db: Path to the Plex SQLite database file (required)-id: Specific playlist ID to extract (0 = extract all, default: 0)-output: Output directory for M3U files (default: ./playlists)-list: List all available playlists and exit
The Plex database is typically located at:
- Windows:
%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db - macOS:
~/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db - Linux:
~/.local/share/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
The program generates M3U files in the standard format:
#EXTM3U
#PLAYLIST:My Awesome Playlist
#COMMENT:Description of the playlist
#EXTINF:245,Artist Name - Song Title
/path/to/song1.mp3
#EXTINF:180,Another Artist - Another Song
/path/to/song2.mp3
When extracting playlists, you'll see output like:
Extracting 5 playlists...
✓ Extracted 'My Favorites' (25 tracks) to ./playlists/My_Favorites.m3u
✓ Extracted 'Workout Mix' (15 tracks) to ./playlists/Workout_Mix.m3u
✓ Extracted 'Chill Vibes' (30 tracks) to ./playlists/Chill_Vibes.m3u
Extraction complete: 3/5 playlists successfully extracted
The program handles various error conditions gracefully:
- Missing database files
- Invalid playlist IDs
- Database connection issues
- File writing errors
- Invalid file paths
Comprehensive documentation about the Plex database structure and playlist extraction is available in the docs/ directory:
- Database Overview - Quick reference for essential tables
- Playlist Extraction Guide - Detailed SQL queries and examples
- Common Query Patterns - Useful SQL patterns for Plex databases
- Database Relationships - Understanding table relationships
- Complete Database Schemas - Full reference for all Plex databases
- modernc.org/sqlite - Pure Go SQLite driver
This project is open source. Feel free to modify and distribute as needed.
Contributions are welcome! Please feel free to submit issues and pull requests.