From cda8120b6d3d1fe90d70a4b79d1255032effc34a Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Sat, 16 May 2026 10:54:24 -0600 Subject: [PATCH] fix(title): use original-language audio for filename metadata When a non-original audio language is the default (via muxing.default_language or sort order), the filename audio codec/channel fields still reflect the title's original-language track instead of whichever track appears first in the muxed MKV. --- unshackle/core/titles/title.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/unshackle/core/titles/title.py b/unshackle/core/titles/title.py index db444b3..579cbe8 100644 --- a/unshackle/core/titles/title.py +++ b/unshackle/core/titles/title.py @@ -61,7 +61,21 @@ class Title: returned dict with their specific fields (e.g., season/episode). """ primary_video_track = next(iter(media_info.video_tracks), None) - primary_audio_track = next(iter(media_info.audio_tracks), None) + original_lang_tag = ( + str(self.language).split("-")[0].lower() if self.language else "" + ) + primary_audio_track = None + if original_lang_tag: + primary_audio_track = next( + ( + t + for t in media_info.audio_tracks + if t.language and t.language.split("-")[0].lower() == original_lang_tag + ), + None, + ) + if primary_audio_track is None: + primary_audio_track = next(iter(media_info.audio_tracks), None) unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language}) context: dict[str, Any] = { @@ -143,8 +157,6 @@ class Title: channel_count = primary_audio_track.channel_s or primary_audio_track.channels or 0 channels = float(channel_count) - features = primary_audio_track.format_additionalfeatures or "" - has_atmos = any( "JOC" in (t.format_additionalfeatures or "") or t.joc for t in media_info.audio_tracks )