Last active
November 14, 2016 05:07
-
-
Save oxguy3/e2b1f80bf1e4d19a1b9e779bc244035c to your computer and use it in GitHub Desktop.
Tag anime as japanese
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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