Skip to content

Instantly share code, notes, and snippets.

@oxguy3 oxguy3/languify.sh
Last active Nov 14, 2016

Embed
What would you like to do?
Tag anime as japanese
#!/bin/bash
# Tag videos as a given language
# Examples:
# Tag a single MP4 video as Japanese:
# ./languify.sh jpn Attack on Titan Episode 1.mp4
# Tag all MP4 files in the directory as English:
# ./languify.sh eng % mp4
function erroranddie {
echo "Invalid command! Syntax: ./languify.sh <lang> <file> OR ./languify.sh <lang> % <ext>"
}
function languify {
if [ -z "$1" ] || [ -z "$2" ] ; then
erroranddie
fi
langcode="$1"
infiles="${@:2}"
mkdir out plexignore
# add language tag to all files
ffmpeg -i "$infiles" -metadata:s:a:0 language=$langcode -codec copy -map 0 "out/$infiles"
# get old files outta here
mv "$infiles" "plexignore/$infiles"
# move new files to this directory
cd out
mv "$infiles" "../$infiles"
# burn the evidence
cd ..
rm -rf out
rm -rf plexignore
}
if [ -z "$1" ] || [ -z "$2" ] ; then
erroranddie
fi
if [ "$2" == "%" ] ; then
if [ -z "$3" ] ; then
erroranddie
fi
infiles="*."$3
for f in $infiles; do
languify $1 $f
done
else
filename="${@:2}"
languify $1 $filename
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.