Skip to content

manifoldcuriosity/media-tools

Repository files navigation

Media Tools

A collection of Python scripts for media library organization and Lidarr maintenance on Unraid.

Lidarr Maintenance Scripts

These scripts fix common issues with Lidarr on Linux (case-sensitivity, folder naming, etc.)

fix_folder_names.py

Comprehensive folder name sync between Lidarr database and filesystem.

Problems Solved:

  • Disambiguation suffixes: Johnny Cash (country music legend)Johnny Cash
  • Unicode/special chars: Jay-ZJAY‐Z, Bela BartokBé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 --execute

fix_case_mismatches.py

Fixes case-only mismatches between Lidarr DB and filesystem.

Linux is case-sensitive, so Ludwig Van BeethovenLudwig van Beethoven. This causes MediaFileDeletionService errors.

python3 fix_case_mismatches.py           # Dry run
python3 fix_case_mismatches.py --execute # Apply changes

lidarr_batch_search.py

Automated 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.log

lidarr_folder_renamer.py

Renames album folders to consistent format: {Artist} - {AlbumType} - {Year} {Title}

python3 lidarr_folder_renamer.py --dry-run  # Preview
python3 lidarr_folder_renamer.py            # Execute

Media Organization Scripts

delete_empty_music_folders.py

Recursively 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  # Execute

merge_similar_artists.py

Merges artist folders with similar names (handles case differences, accents, etc.)

audiobooks_duplicate_detector.py

Detects duplicate audiobook folders (case-insensitive comparison).

Utility Scripts

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

Configuration

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"

Unraid User Scripts

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

Requirements

  • Python 3.6+
  • requests library (for Lidarr API scripts)
  • SQLite3 (included with Python)

License

MIT

About

Media organization and Lidarr maintenance scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages