Prefer the English caption track (label-based, not first-track)

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.
This commit is contained in:
jozamudi committed 2026-09-07 03:01:38 +00:00
1 parent 5b8170ece0
commit 65da3e848f
1 file changed
+7 -2
+7 -2
View File
@@ -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