From ac47243eb4ad10910fb3b48baf30593b25d090b9 Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Tue, 4 Mar 2025 23:09:47 -0500 Subject: [PATCH] bleh --- TODO.md | 6 ++++++ detect_missing_fonts.sh | 27 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..a457f7a --- /dev/null +++ b/TODO.md @@ -0,0 +1,6 @@ +# TODO +[ ] Write script to remove images embedded in mkv +[ ] Write script to remove unwanted audio tracks in mkv +[ ] Write script to remove unwanted subtitle tracks in mkv +[ ] Write script to discard PGS subtitle tracks if ASS subtitle tracks exist +[ ] Write a script to make the first audio track in a language the default \ No newline at end of file diff --git a/detect_missing_fonts.sh b/detect_missing_fonts.sh index f312ef2..54a8235 100755 --- a/detect_missing_fonts.sh +++ b/detect_missing_fonts.sh @@ -1,18 +1,29 @@ #!/bin/bash -# Function to check attachments in a file +# Function to check if the file contains SSA/ASS subtitles +contains_ssa_ass() { + local file="$1" + if mkvmerge -i "$file" | grep -iqE "subtitles.*\(SSA\|ASS\)"; then + return 0 # Found SSA/ASS subtitles + else + return 1 # No SSA/ASS subtitles + fi +} + +# Function to check if the file has attachments check_attachments() { local file="$1" - # Use mkvinfo to get the details of the file, specifically looking for 'attachments' - if ! mkvmerge -i "$file" | grep -q "Attachment"; then - # If there are no attachments, print the filename + if ! mkvinfo "$file" | grep -q "Attachment"; then echo "$file" fi } -# Export the function so it can be used with find +export -f contains_ssa_ass export -f check_attachments -# Recursively find all .mkv files and check for attachments -find . -type f -name "*.mkv" -exec bash -c 'check_attachments "$0"' {} \; - +# Find all .mkv files and process them +find . -type f -name "*.mkv" | while read -r file; do + if contains_ssa_ass "$file"; then + check_attachments "$file" + fi +done