From 65da3e848f803c07b2c66a1265f4b28c942045e5 Mon Sep 17 00:00:00 2001 From: Josue Zamudio Date: Mon, 7 Sep 2026 03:01:38 +0000 Subject: [PATCH] Prefer the English caption track (label-based, not first-track) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hianime's subtitle 'lang' field is useless (everything says 'en'); the real language is the label, and it is not always first — Chainsaw Man E1 leads with Arabic. Pick label=='English', fall back to first track. --- server/providers/hianime.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/providers/hianime.py b/server/providers/hianime.py index 741879b..ff8442f 100644 --- a/server/providers/hianime.py +++ b/server/providers/hianime.py @@ -109,8 +109,13 @@ def _master_m3u8(ep_id, lang="eng"): hosts.add(urlparse(urljoin(master, line)).netloc) STREAM_HOSTS |= hosts subs = j.get("subtitles") or [] - if subs and (subs[0] or {}).get("src"): - SUBS[ep_id] = subs[0]["src"] # first track is the english one + # the 'lang' field is useless (everything says 'en'); the real language + # is the label — and it isn't first (Chainsaw Man E1 leads with Arabic) + pick = next((x for x in subs if (x or {}).get("label", "").lower() == "english"), None) + if not pick and subs: + pick = subs[0] + if pick and pick.get("src"): + SUBS[ep_id] = pick["src"] return master return None