The: Dark Knight Trilogy 1080p Bdrip Aac X264-to...

def verify_integrity(filepath): """Check for corruption by attempting to read first/last frames.""" cmd = ['ffmpeg', '-v', 'error', '-i', str(filepath), '-f', 'null', '-'] result = subprocess.run(cmd, capture_output=True, text=True) return result.stderr == "" # True if no errors

match = PATTERN.search(filepath.name) if not match: print(f"Skipping (no match): filepath.name") continue

#!/usr/bin/env python3 """ Media File Organizer for files named like: "The Dark Knight Trilogy 1080p BDRip AAC x264-to..." Parses scene naming, renames to clean format, checks bitrate, and verifies audio. """ import re import os import sys import subprocess from pathlib import Path Example input: "The Dark Knight Trilogy 1080p BDRip AAC x264-to..." PATTERN = re.compile( r'^(?P<title>.+?)\s+' # Title (lazy match) r'(?P<resolution>\d3,4p)\s+' # 720p, 1080p, 2160p r'(?P<source>BDRip|WEB-DL|BluRay)\s+' # Source r'(?P<audio>AAC|DTS|AC3)\s+' # Audio codec r'(?P<video>x264|x265|AV1)\s*' # Video codec r' -– ?' # Release group (optional) r'(?P<ext>.mkv|.mp4|.avi)$' # Extension ) THE DARK KNIGHT TRILOGY 1080p BDRip AAC x264-to...

if not dry_run: # Rename file filepath.rename(new_path) # Verify integrity if verify_integrity(new_path): print(" ✓ Integrity check passed") else: print(" ✗ WARNING: File may be corrupted")

# Show actual codec info info = get_media_info(new_path) if info: # Extract video bitrate, audio channels (simplified) if 'video' in info and 'bit_rate' in info: print(" ✓ Media info extracted") else: print(" (dry run, no changes made)") if == " main ": if len(sys.argv) < 2: print(f"Usage: sys.argv[0] /path/to/movies [--do-it]") sys.exit(1) '-'] result = subprocess.run(cmd

The Dark Knight Trilogy (1080p).mkv The Dark Knight 2008 (1080p).mkv And it will alert you if any file is incomplete or corrupted.

The Dark Knight Trilogy 1080p BDRip AAC x264-toxx.mkv The Dark Knight 2008 1080p BDRip DTS x264-toxx.mkv renames to clean format

def clean_filename(match): """Convert parsed scene name to a Plex-friendly format.""" groups = match.groupdict() # Example output: "The Dark Knight Trilogy (1080p).mkv" return f"groups['title'] (groups['resolution'])groups['ext']"

new_name = clean_filename(match) new_path = filepath.with_name(new_name)