|
|
|
|
@ -30,9 +30,10 @@ _mkvmerge_add_subtitles_mkvmerge () {
|
|
|
|
|
# For example [basename].[language code].srt
|
|
|
|
|
coded_subtitle_files=(${original_file:r}.*.srt(N))
|
|
|
|
|
if [[ ! -z $coded_subtitle_files ]]; then
|
|
|
|
|
for fname in "$coded_subtitle_files"; do
|
|
|
|
|
for fname in $coded_subtitle_files; do
|
|
|
|
|
language_code="${${fname:r}:e}"
|
|
|
|
|
subtitle_options_array+=("--language" "0:${language_code}" "$fname")
|
|
|
|
|
echo "Found coded subtitle file ${fname} for language ${language_code}."
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
@ -41,6 +42,8 @@ _mkvmerge_add_subtitles_mkvmerge () {
|
|
|
|
|
uncoded_subtitle_name="${original_file:r}.srt"
|
|
|
|
|
if [[ -f "$uncoded_subtitle_name" ]]; then
|
|
|
|
|
subtitle_options_array+=("--language" "0:${DEFAULT_LANGUAGE_CODE}" "$uncoded_subtitle_name")
|
|
|
|
|
echo "Found uncoded subtitle file ${uncoded_subtitle_name}, assuming \
|
|
|
|
|
${DEFAULT_LANGUAGE_CODE}."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Finally, actually mux all the subtitles in if there are any.
|
|
|
|
|
@ -48,7 +51,7 @@ _mkvmerge_add_subtitles_mkvmerge () {
|
|
|
|
|
echo "No subtitles found for file ${original_file}"
|
|
|
|
|
else
|
|
|
|
|
echo "Remuxing ${original_file}..."
|
|
|
|
|
mkvmerge --quiet -o "$partial_file" "$original_file" ${(@)subtitle_options_array} \
|
|
|
|
|
mkvmerge --quiet -o "$partial_file" "$original_file" ${^subtitle_options_array} \
|
|
|
|
|
|| rm "$partial_file"
|
|
|
|
|
echo "Done!"
|
|
|
|
|
|
|
|
|
|
|