feat(tracks): name unnamed tracks by language and tag subtitle scripts

Unnamed tracks get the English language name (default region left out); subtitle tags gain the script their region implies (zh-TW -> zh-Hant-TW). Refs #169
This commit is contained in:
imSp4rky
2026-10-24 10:59:21 -06:00
parent 83514d12fe
commit 1175035317
10 changed files with 278 additions and 35 deletions
+7 -1
View File
@@ -15,6 +15,7 @@ import click
import pycaption
import requests
from construct import Container
from langcodes import Language
from pycaption import Caption, CaptionList, CaptionNode, WebVTTReader
from pycaption.geometry import Layout
from pymp4.parser import MP4
@@ -24,7 +25,7 @@ from subtitle_filter import Subtitles
from unshackle.core import binaries
from unshackle.core.config import config
from unshackle.core.tracks.track import Track
from unshackle.core.utilities import try_ensure_utf8
from unshackle.core.utilities import try_ensure_utf8, with_script
from unshackle.core.utils.subprocess import log_tool_run
from unshackle.core.utils.webvtt import merge_segmented_webvtt
@@ -221,6 +222,11 @@ class Subtitle(Track):
forced=data.get("forced", False),
)
@property
def mux_language(self) -> Language:
"""The language tag written to the output file, with the script its region implies."""
return with_script(self.language)
def __str__(self) -> str:
return " | ".join(
filter(