.
This commit is contained in:
@@ -206,11 +206,143 @@ find_subs_dir() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------- subtitle meta (no language override) ----------------
|
|
||||||
|
# ---------------- language "database" for display names (GERMAN) ----------------
|
||||||
|
# Maps ISO 639-1/2 codes to German display names
|
||||||
|
declare -A LANG_DB=(
|
||||||
|
# Deutsch
|
||||||
|
[de]="Deutsch" [deu]="Deutsch" [ger]="Deutsch"
|
||||||
|
# Englisch
|
||||||
|
[en]="Englisch" [eng]="Englisch"
|
||||||
|
# Französisch
|
||||||
|
[fr]="Französisch" [fra]="Französisch" [fre]="Französisch"
|
||||||
|
# Spanisch
|
||||||
|
[es]="Spanisch" [spa]="Spanisch"
|
||||||
|
# Italienisch
|
||||||
|
[it]="Italienisch" [ita]="Italienisch"
|
||||||
|
# Niederländisch
|
||||||
|
[nl]="Niederländisch" [nld]="Niederländisch" [dut]="Niederländisch"
|
||||||
|
# Polnisch
|
||||||
|
[pl]="Polnisch" [pol]="Polnisch"
|
||||||
|
# Russisch
|
||||||
|
[ru]="Russisch" [rus]="Russisch"
|
||||||
|
# Portugiesisch
|
||||||
|
[pt]="Portugiesisch" [por]="Portugiesisch"
|
||||||
|
# Türkisch
|
||||||
|
[tr]="Türkisch" [tur]="Türkisch"
|
||||||
|
# Schwedisch
|
||||||
|
[sv]="Schwedisch" [swe]="Schwedisch"
|
||||||
|
# Norwegisch
|
||||||
|
[no]="Norwegisch" [nor]="Norwegisch"
|
||||||
|
# Dänisch
|
||||||
|
[da]="Dänisch" [dan]="Dänisch"
|
||||||
|
# Finnisch
|
||||||
|
[fi]="Finnisch" [fin]="Finnisch"
|
||||||
|
# Tschechisch
|
||||||
|
[cs]="Tschechisch" [ces]="Tschechisch" [cze]="Tschechisch"
|
||||||
|
# Ungarisch
|
||||||
|
[hu]="Ungarisch" [hun]="Ungarisch"
|
||||||
|
# Rumänisch
|
||||||
|
[ro]="Rumänisch" [ron]="Rumänisch" [rum]="Rumänisch"
|
||||||
|
# Bulgarisch
|
||||||
|
[bg]="Bulgarisch" [bul]="Bulgarisch"
|
||||||
|
# Griechisch
|
||||||
|
[el]="Griechisch" [ell]="Griechisch" [gre]="Griechisch"
|
||||||
|
# Hebräisch
|
||||||
|
[he]="Hebräisch" [heb]="Hebräisch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Extract language code from VobSub .idx (first "id:" line), lowercased.
|
||||||
|
# Example line: "id: en, index: 0"
|
||||||
|
idx_lang_from_file() {
|
||||||
|
local idx="$1"
|
||||||
|
local code=""
|
||||||
|
|
||||||
|
code="$(awk '
|
||||||
|
BEGIN{IGNORECASE=1}
|
||||||
|
/^[ \t]*id:[ \t]*[a-z][a-z][a-z]?[ \t]*,/ {
|
||||||
|
gsub(/^[ \t]*/, "", $0)
|
||||||
|
sub(/^id:[ \t]*/, "", $0)
|
||||||
|
sub(/,.*/, "", $0)
|
||||||
|
print tolower($0)
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
/^[ \t]*id:[ \t]*[a-z][a-z][a-z]?[ \t]*$/ {
|
||||||
|
gsub(/^[ \t]*/, "", $0)
|
||||||
|
sub(/^id:[ \t]*/, "", $0)
|
||||||
|
print tolower($0)
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
' "$idx" 2>/dev/null || true)"
|
||||||
|
|
||||||
|
[[ -n "$code" ]] && printf '%s' "$code"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Try to infer a language "code" from filename tokens (best effort).
|
||||||
|
# Returns: code or empty
|
||||||
|
lang_code_from_filename() {
|
||||||
|
local stem="$1"
|
||||||
|
local lc="${stem,,}"
|
||||||
|
|
||||||
|
# English tokens
|
||||||
|
if [[ "$lc" =~ (^|[._\ \-])eng([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])en([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" == *english* ]]; then
|
||||||
|
printf 'en'; return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# German tokens
|
||||||
|
if [[ "$lc" =~ (^|[._\ \-])deu([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])ger([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])de([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" == *german* ]]; then
|
||||||
|
printf 'de'; return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# French tokens
|
||||||
|
if [[ "$lc" =~ (^|[._\ \-])fra([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])fre([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])fr([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" == *french* ]]; then
|
||||||
|
printf 'fr'; return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Spanish tokens
|
||||||
|
if [[ "$lc" =~ (^|[._\ \-])spa([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])es([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" == *spanish* ]]; then
|
||||||
|
printf 'es'; return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Italian tokens
|
||||||
|
if [[ "$lc" =~ (^|[._\ \-])ita([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" =~ (^|[._\ \-])it([._\ \-]|$) ]] || \
|
||||||
|
[[ "$lc" == *italian* ]]; then
|
||||||
|
printf 'it'; return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add more here if you want...
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Convert a language code to a nice name using LANG_DB.
|
||||||
|
# Returns: name or empty
|
||||||
|
lang_name_from_code() {
|
||||||
|
local code="${1,,}"
|
||||||
|
[[ -n "${LANG_DB[$code]:-}" ]] && printf '%s' "${LANG_DB[$code]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Echoes: track_name|forcedFlag
|
# Echoes: track_name|forcedFlag
|
||||||
|
# Strategy:
|
||||||
|
# 1) Prefer filename tokens (more reliable for scene releases)
|
||||||
|
# 2) If filename gives no hint -> read idx "id: xx" and map to display name
|
||||||
|
# 3) If still unknown -> empty name (=> don't set --track-name)
|
||||||
infer_meta_for_idx() {
|
infer_meta_for_idx() {
|
||||||
local idx="$1"
|
local idx="$1"
|
||||||
local stem lc forced name
|
local stem lc forced name code_file code_idx
|
||||||
|
|
||||||
stem="$(basename "$idx" .idx)"
|
stem="$(basename "$idx" .idx)"
|
||||||
lc="${stem,,}"
|
lc="${stem,,}"
|
||||||
@@ -218,19 +350,37 @@ infer_meta_for_idx() {
|
|||||||
forced="no"
|
forced="no"
|
||||||
[[ "$lc" == *forced* ]] && forced="yes"
|
[[ "$lc" == *forced* ]] && forced="yes"
|
||||||
|
|
||||||
# Track name heuristic (display only, not language)
|
name=""
|
||||||
if [[ "$lc" =~ (^|[._\ \-])eng([._\ \-]|$) ]] || [[ "$lc" == *english* ]]; then
|
|
||||||
name="English"
|
# 1) from filename
|
||||||
elif [[ "$lc" =~ (^|[._\ \-])de([._\ \-]|$) ]] || [[ "$lc" == *german* ]] || [[ "$lc" =~ (^|[._\ \-])ger([._\ \-]|$) ]] || [[ "$lc" == *deu* ]]; then
|
code_file="$(lang_code_from_filename "$stem" || true)"
|
||||||
name="Deutsch"
|
if [[ -n "${code_file:-}" ]]; then
|
||||||
else
|
name="$(lang_name_from_code "$code_file" || true)"
|
||||||
name="$stem"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "$forced" == "yes" ]] && name+=" (Forced)"
|
# 2) fallback: from idx file content
|
||||||
|
if [[ -z "$name" ]]; then
|
||||||
|
code_idx="$(idx_lang_from_file "$idx" || true)"
|
||||||
|
if [[ -n "${code_idx:-}" ]]; then
|
||||||
|
name="$(lang_name_from_code "$code_idx" || true)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Optional: warn on mismatch if both exist (filename wins)
|
||||||
|
if [[ -n "${code_file:-}" ]]; then
|
||||||
|
code_idx="$(idx_lang_from_file "$idx" || true)"
|
||||||
|
if [[ -n "${code_idx:-}" && "$code_idx" != "$code_file" ]]; then
|
||||||
|
dbg "WARN: language mismatch for $(basename "$idx"): filename=$code_file, idx=$code_idx (using filename)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -n "$name" && "$forced" == "yes" ]] && name+=" (Forced)"
|
||||||
echo "${name}|${forced}"
|
echo "${name}|${forced}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------- mux one mkv ----------------
|
# ---------------- mux one mkv ----------------
|
||||||
mux_one_mkv() {
|
mux_one_mkv() {
|
||||||
local mkv="$1"
|
local mkv="$1"
|
||||||
@@ -282,7 +432,10 @@ mux_one_mkv() {
|
|||||||
dbg "Add VobSub: $(basename "$idx") -> name='$name', forced=$forcedFlag"
|
dbg "Add VobSub: $(basename "$idx") -> name='$name', forced=$forcedFlag"
|
||||||
|
|
||||||
# IMPORTANT: do NOT override language; keep what is in the .idx
|
# IMPORTANT: do NOT override language; keep what is in the .idx
|
||||||
|
if [[ -n "$name" ]]; then
|
||||||
cmd+=( --track-name 0:"$name" )
|
cmd+=( --track-name 0:"$name" )
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$forcedFlag" == "yes" ]]; then
|
if [[ "$forcedFlag" == "yes" ]]; then
|
||||||
cmd+=( --forced-track 0:yes --default-track 0:no )
|
cmd+=( --forced-track 0:yes --default-track 0:no )
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user