diff --git a/lib/svtplay_dl/fetcher/dash.py b/lib/svtplay_dl/fetcher/dash.py index 3c96c33..47a0bad 100644 --- a/lib/svtplay_dl/fetcher/dash.py +++ b/lib/svtplay_dl/fetcher/dash.py @@ -281,6 +281,9 @@ def _dashparse(config, text, url, output, cookies, **kwargs): **kwargs, ) for sub in subtitles: + if len(subtitles) > 1: + if sub["role"] and sub["role"] != "main" and sub["role"] != "subtitle": + sub["lang"] = f'{sub["lang"]}-{sub["role"]}' yield from subtitle_probe(copy.copy(config), url, subfix=sub["lang"], output=copy.copy(loutput), files=sub["files"], **kwargs) diff --git a/lib/svtplay_dl/fetcher/hls.py b/lib/svtplay_dl/fetcher/hls.py index a9d8652..3cf990c 100644 --- a/lib/svtplay_dl/fetcher/hls.py +++ b/lib/svtplay_dl/fetcher/hls.py @@ -89,13 +89,16 @@ def _hlsparse(config, text, url, output, **kwargs): segments = False if i["TYPE"] == "SUBTITLES": if "URI" in i: + caption = None if i["GROUP-ID"] not in subtitles: subtitles[i["GROUP-ID"]] = [] if "LANGUAGE" in i: lang = i["LANGUAGE"] else: lang = "und" - item = [i["URI"], lang] + if "CHARACTERISTICS" in i: + caption = True + item = [i["URI"], lang, caption] if item not in subtitles[i["GROUP-ID"]]: subtitles[i["GROUP-ID"]].append(item) continue @@ -165,8 +168,12 @@ def _hlsparse(config, text, url, output, **kwargs): if subtitles: for sub in list(subtitles.keys()): for n in subtitles[sub]: + subfix = n[2] + if len(subtitles[sub]) > 1: + if subfix: + subfix = f"{n[1]}-caption" yield from subtitle_probe( - copy.copy(config), get_full_url(n[0], url), output=copy.copy(output), subfix=n[1], cookies=cookies, **kwargs + copy.copy(config), get_full_url(n[0], url), output=copy.copy(output), subfix=subfix, cookies=cookies, **kwargs ) elif m3u8.media_segment: diff --git a/lib/svtplay_dl/subtitle/__init__.py b/lib/svtplay_dl/subtitle/__init__.py index b08f118..62c6828 100644 --- a/lib/svtplay_dl/subtitle/__init__.py +++ b/lib/svtplay_dl/subtitle/__init__.py @@ -32,7 +32,7 @@ def subtitle_probe(config, url, **kwargs): elif subdata.text.startswith("#EXTM3U"): m3u8 = M3U8(subdata.text) yield subtitle(config, "wrstsegment", url, **kwargs, m3u8=m3u8) - elif "" + return f"" def download(self): output_ext = "srt"