From 68ef786450e5dbee14c5cccd0c82d224736a59d5 Mon Sep 17 00:00:00 2001 From: DemonGatanjieu <1027066412@qq.com> Date: Tue, 22 Sep 2026 23:56:00 +0800 Subject: [PATCH] feat(audio): support companion .orig.txt for native script display in audio cards --- api/audio_catalog.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/api/audio_catalog.py b/api/audio_catalog.py index 1ef78b9..5a15ca6 100644 --- a/api/audio_catalog.py +++ b/api/audio_catalog.py @@ -24,13 +24,23 @@ def _parse_character_and_emotion(filename): def _read_associated_text(base_path): - """Read companion prompt text file if present.""" + """Read companion prompt text file if present (preferring .orig.txt for display).""" stem, _ = os.path.splitext(base_path) + orig_path = stem + '.orig.txt' + if os.path.isfile(orig_path): + try: + with open(orig_path, 'r', encoding='utf-8-sig', errors='ignore') as f: + content = f.read().strip().lstrip('\ufeff') + if content: + return content + except Exception: + pass + txt_path = stem + '.txt' if os.path.isfile(txt_path): try: - with open(txt_path, 'r', encoding='utf-8', errors='ignore') as f: - return f.read().strip() + with open(txt_path, 'r', encoding='utf-8-sig', errors='ignore') as f: + return f.read().strip().lstrip('\ufeff') except Exception: return "" return ""