Skip to content

hydronica/go-plex-playlist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plex Playlist Extractor

A Go program that extracts music playlists from a Plex Media Server SQLite database and exports them to M3U format files.

Features

  • 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

Installation

  1. Make sure you have Go 1.21 or later installed
  2. Clone or download this repository
  3. Install dependencies:
    go mod tidy
  4. Build the program:
    go build -o plex-playlist-extractor

Usage

Basic Usage

# 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

Command Line Options

  • -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

Finding Your Plex Database

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

Output Format

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

Example Output

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

Error Handling

The program handles various error conditions gracefully:

  • Missing database files
  • Invalid playlist IDs
  • Database connection issues
  • File writing errors
  • Invalid file paths

Documentation

Comprehensive documentation about the Plex database structure and playlist extraction is available in the docs/ directory:

Dependencies

License

This project is open source. Feel free to modify and distribute as needed.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages