feat: change naming system to better reflect included languages
This commit is contained in:
@@ -8,6 +8,26 @@ import sys
|
|||||||
from .config import AUDIO_CODEC_SCENE, CHANNEL_SCENE
|
from .config import AUDIO_CODEC_SCENE, CHANNEL_SCENE
|
||||||
|
|
||||||
|
|
||||||
|
# ISO 639-2/B → ISO 639-1 (uppercase) for common languages
|
||||||
|
_LANG_MAP = {
|
||||||
|
"eng": "EN", "deu": "DE", "ger": "DE", "fra": "FR", "fre": "FR",
|
||||||
|
"spa": "ES", "ita": "IT", "por": "PT", "nld": "NL", "dut": "NL",
|
||||||
|
"rus": "RU", "jpn": "JA", "zho": "ZH", "chi": "ZH", "kor": "KO",
|
||||||
|
"ara": "AR", "hin": "HI", "pol": "PL", "tur": "TR", "swe": "SV",
|
||||||
|
"nor": "NO", "dan": "DA", "fin": "FI", "ces": "CS", "cze": "CS",
|
||||||
|
"hun": "HU", "ron": "RO", "rum": "RO", "bul": "BG", "hrv": "HR",
|
||||||
|
"slk": "SK", "slo": "SK", "slv": "SL", "ukr": "UK", "ell": "EL",
|
||||||
|
"gre": "EL", "heb": "HE", "tha": "TH", "vie": "VI", "ind": "ID",
|
||||||
|
"msa": "MS", "may": "MS", "cat": "CA", "eus": "EU", "baq": "EU",
|
||||||
|
"glg": "GL", "lat": "LA", "und": "UND",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _iso639_to_2letter(code: str) -> str:
|
||||||
|
"""Convert ISO 639-2/B code to uppercase 2-letter ISO 639-1."""
|
||||||
|
return _LANG_MAP.get(code.lower(), code.upper()[:2])
|
||||||
|
|
||||||
|
|
||||||
def get_resolution_tag(title: dict) -> str:
|
def get_resolution_tag(title: dict) -> str:
|
||||||
"""Return a scene-style resolution tag like 1080p, 2160p, 720p."""
|
"""Return a scene-style resolution tag like 1080p, 2160p, 720p."""
|
||||||
height = title.get("Geometry", {}).get("Height", 0)
|
height = title.get("Geometry", {}).get("Height", 0)
|
||||||
@@ -123,6 +143,8 @@ def build_scene_name(
|
|||||||
title: dict,
|
title: dict,
|
||||||
audio_tracks: list[dict],
|
audio_tracks: list[dict],
|
||||||
source_tag: str,
|
source_tag: str,
|
||||||
|
codec_tag: str = "x265",
|
||||||
|
is_10bit: bool = True,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Build a scene-style filename (without extension).
|
Build a scene-style filename (without extension).
|
||||||
@@ -141,8 +163,9 @@ def build_scene_name(
|
|||||||
|
|
||||||
parts.append(get_resolution_tag(title))
|
parts.append(get_resolution_tag(title))
|
||||||
parts.append(source_tag)
|
parts.append(source_tag)
|
||||||
parts.append("10bit")
|
if is_10bit:
|
||||||
parts.append("x265")
|
parts.append("10bit")
|
||||||
|
parts.append(codec_tag)
|
||||||
|
|
||||||
# Primary audio tag (best quality track overall)
|
# Primary audio tag (best quality track overall)
|
||||||
if audio_tracks:
|
if audio_tracks:
|
||||||
@@ -152,10 +175,15 @@ def build_scene_name(
|
|||||||
)
|
)
|
||||||
parts.append(scene_audio_tag(primary))
|
parts.append(scene_audio_tag(primary))
|
||||||
|
|
||||||
# Multi-language count
|
# Language tag: use ISO codes for ≤3 languages, MULTI-N for more
|
||||||
langs = {t.get("LanguageCode", "und") for t in audio_tracks}
|
langs = list(dict.fromkeys(
|
||||||
if len(langs) > 1:
|
t.get("LanguageCode", "und") for t in audio_tracks
|
||||||
|
)) # unique, order-preserving
|
||||||
|
if len(langs) > 3:
|
||||||
parts.append(f"MULTI-{len(langs)}.Audio")
|
parts.append(f"MULTI-{len(langs)}.Audio")
|
||||||
|
elif len(langs) > 1:
|
||||||
|
parts.append(".".join(_iso639_to_2letter(l) for l in langs))
|
||||||
|
# Single language: no tag needed (implied)
|
||||||
|
|
||||||
return ".".join(parts)
|
return ".".join(parts)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user