Libretto is a powerful Python tool that exports detailed information from your Plex Media Server libraries into CSV format. It supports movies, TV shows, and music libraries with rich metadata extraction.
- Export complete library metadata to CSV files
- Support for Movies, TV Shows, and Music libraries
- Detailed metadata including titles, ratings, release dates, technical specifications, and more
- Paginated data retrieval to handle large libraries efficiently
- Configurable output locations
- Progress tracking with colorful console output
- Robust error handling and logging
- Python 3.6 or higher
- A Plex Media Server
- Plex authentication token
requests
urllib3
colorama
- Clone the repository:
git clone git@github.com:jeremehancock/Libretto.git
- Change directory:
cd Libretto
- Install required packages:
pip install -r requirements.txt
Libretto can be configured either through command-line arguments or a configuration file. On first run, a default configuration file will be created at config/libretto.conf
.
# Libretto (for Plex) Configuration File
# Location: config/libretto.conf
###################
# Server Settings #
###################
# Plex server URL (required)
PLEX_URL="http://localhost:32400"
# Your Plex authentication token (required)
# To find your token: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
PLEX_TOKEN=""
###################
# Export Settings #
###################
# Default output directory for exports
OUTPUT_DIR="exports"
# Force overwrite existing files (true/false)
FORCE=false
###################
# Debug Settings #
###################
# Enable debug mode (true/false)
DEBUG=false
# Enable logging (true/false)
ENABLE_LOGGING=false
# Whether to run in quiet mode (true/false)
QUIET=false
You can modify these settings by editing the file directly or override them using command-line options.
If you haven't set your Plex token in the config file:
./libretto.py -t YOUR_PLEX_TOKEN [options]
If you've already set your Plex token in the config file:
./libretto.py [options]
-t, --token TOKEN Plex authentication token (required)
-u, --url URL Plex server URL (default: http://localhost:32400)
-l, --list List all libraries
-n, --name NAME Export specific library by name
-o, --output FILE Output file
-d, --dir DIR Output directory (default: exports)
-f, --force Force overwrite of existing files
-q, --quiet Quiet mode (no stdout output)
-v, --debug Debug mode (verbose output)
--version Show version information
The movie export includes:
- Basic information (title, year, duration)
- Technical details (resolution, audio/video codecs)
- Metadata (ratings, genres, cast, crew)
- File information (size, container format)
- Timestamps (added, updated)
The TV show export includes:
- Series information (title, episodes, seasons)
- Metadata (ratings, genres, cast)
- Air dates and availability
- Production details (studio, content rating)
The music export includes:
- Artist and album information
- Release year
- Genres
- Studio/Label
- Added/Updated timestamps
libretto/
├── libretto.py # Main script
├── config/ # Configuration files
│ └── libretto.conf
├── exports/ # Default export directory
├── logs/ # Log files
└── requirements.txt # Requirements file
Libretto includes comprehensive error handling:
- File system permission checks
- Network connectivity issues
- Invalid authentication
- Malformed responses
- Concurrent execution prevention
Libretto includes imports for Radarr and Sonarr. Check them out here.
Libretto needs to be on the same network as your Plex Media Server to run.
If you want to connect remotely you will need to use something like Tailscale to ensure that Libretto can communicate with your Plex Media Server.
This tool was developed with assistance from AI language models.