A collection of Python scripts for media library organization and Lidarr maintenance on Unraid.
These scripts fix common issues with Lidarr on Linux (case-sensitivity, folder naming, etc.)
Comprehensive folder name sync between Lidarr database and filesystem.
Problems Solved:
- Disambiguation suffixes:
Johnny Cash (country music legend)→Johnny Cash - Unicode/special chars:
Jay-Z→JAY‐Z,Bela Bartok→Béla Bartók - Punctuation differences:
Skal'pel'→Skalpel - Trailing characters:
clipping_→clipping - Updates TrackFiles table paths automatically
# Dry run (preview changes)
python3 fix_folder_names.py
# Execute changes (run with Lidarr stopped)
python3 fix_folder_names.py --executeFixes case-only mismatches between Lidarr DB and filesystem.
Linux is case-sensitive, so Ludwig Van Beethoven ≠ Ludwig van Beethoven. This causes MediaFileDeletionService errors.
python3 fix_case_mismatches.py # Dry run
python3 fix_case_mismatches.py --execute # Apply changesAutomated batch search for missing albums in Lidarr.
Features:
- Searches missing albums in reverse chronological order
- State tracking (resumes where it left off)
- Configurable batch size and delays
- Auto-restart after completing all albums
# Run in background
nohup python3 lidarr_batch_search.py >> batch_search.log 2>&1 &
# Monitor progress
tail -f batch_search.logRenames album folders to consistent format: {Artist} - {AlbumType} - {Year} {Title}
python3 lidarr_folder_renamer.py --dry-run # Preview
python3 lidarr_folder_renamer.py # ExecuteRecursively finds and deletes folders containing no music files.
python3 delete_empty_music_folders.py /path/to/music # Preview
python3 delete_empty_music_folders.py /path/to/music --delete # ExecuteMerges artist folders with similar names (handles case differences, accents, etc.)
Detects duplicate audiobook folders (case-insensitive comparison).
| Script | Purpose |
|---|---|
fix_trackfiles.py |
Updates TrackFiles table paths in Lidarr DB |
fix_db.py |
Simple DB path updater |
find_mappings.py |
Analyzes folder name mismatches |
Most scripts have configuration variables at the top:
LIDARR_URL = "http://192.168.86.123:8686"
API_KEY = "your-api-key"
MUSIC_PATH = "/mnt/user/Media/Data/Sorted-Music"
DB_PATH = "/mnt/user/appdata/lidarr/lidarr.db"For scheduled execution on Unraid, add to User Scripts plugin:
| Script | Schedule | Command |
|---|---|---|
| Folder Renamer | 0 4 * * * |
python3 /path/to/lidarr_folder_renamer.py |
| Case Fixer | 30 4 * * * |
python3 /path/to/fix_case_mismatches.py --execute |
- Python 3.6+
requestslibrary (for Lidarr API scripts)- SQLite3 (included with Python)
MIT