Compare commits

..

No commits in common. "9d435e9216831bbc7d2d0f836b86ff6c3819aabc" and "50d9961d1917d84f3d51adbfbb77345de91c54ca" have entirely different histories.

1 changed files with 6 additions and 20 deletions

View File

@ -1,8 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail
colorprint() {
echo -e "\e[31m${1}\e[0m"
}
SCRIPT_NAME=$(basename "$0") SCRIPT_NAME=$(basename "$0")
test -z "${1}" && echo "File not specified or doesn't exist, aborting. Usage: $SCRIPT_NAME \$FILENAME" && exit 1 test -z "${1}" && echo "File not specified or doesn't exist, aborting. Usage: $SCRIPT_NAME \$FILENAME" && exit 1
FILE=$1 FILE=$1
@ -10,24 +6,14 @@ FILE=$1
TRACKS=$(mkvmerge --identify "$FILE" | awk -F"[: ]" '$0 ~ /Track ID/{print $3}') TRACKS=$(mkvmerge --identify "$FILE" | awk -F"[: ]" '$0 ~ /Track ID/{print $3}')
# capture JSON output and remove the excessively large code_private_data field # capture JSON output and remove the excessively large code_private_data field
JSON_OUTPUT=$(mkvmerge -J "$FILE" | jq '.tracks[] | del(.properties.codec_private_data)') JSON_OUTPUT=$(mkvmerge -J "$FILE" | jq '.tracks[] | del(.properties.codec_private_data)')
echo -n "Processing "
colorprint "$FILE"
for TRACK in $TRACKS; do for TRACK in $TRACKS; do
TRACK_DATA=$(echo "$JSON_OUTPUT" | jq "select(.id == $TRACK)") TRACK_NAME=$(echo "$JSON_OUTPUT" | jq "select(.id == $TRACK).properties.track_name")
TRACK_NAME=$(echo "$TRACK_DATA" | jq ".properties.track_name") echo -n "Track no. ${TRACK} currently set to $TRACK_NAME... "
TRACK_TYPE=$(echo "$TRACK_DATA" | jq ".type")
TRACK_CODEC=$(echo "$TRACK_DATA" | jq ".codec")
TRACK_LANGUAGE=$(echo "$TRACK_DATA" | jq ".properties.language")
echo -en "\tTrack no. ${TRACK} (${TRACK_TYPE}, ${TRACK_CODEC}, ${TRACK_LANGUAGE})... "
[[ $TRACK_NAME == "null" ]] && echo "has no title, skipping." && continue
echo -n "currently set to $TRACK_NAME... "
shopt -s nocasematch shopt -s nocasematch
[[ $TRACK_NAME =~ full|\stitles|comment|director|sdh|sign ]] && echo "includes whitelisted word, not deleting." && continue [[ $TRACK_NAME =~ full|\stitles|comment|director|sdh|sign ]] && echo "includes whitelisted word, not deleting." && continue
echo -n "deleting... " echo "deleting."
# mkvmerge --identify indexes tracks from 0, while mkvpropedit indexes from 1 # mkvmerge --identify indexes tracks from 0, while mkvpropedit indexes from 1
mkvpropedit "$FILE" --edit track:"$((TRACK+1))" --delete name &>/dev/null mkvpropedit "$FILE" --edit track:"$((TRACK+1))" --delete name
echo "done."
done done
echo -en "\tDeleting file title... " echo "Deleting file title..."
mkvpropedit "$FILE" --edit info --delete title &>/dev/null mkvpropedit "$FILE" --edit info --delete title
echo "done."