From e79bb2b3d3ca1da6da8e51c24b57b15077d846b4 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 20 Oct 2021 15:01:07 +0200 Subject: [PATCH] dr: support for segmented vtt subs --- lib/svtplay_dl/fetcher/hls.py | 2 +- lib/svtplay_dl/subtitle/__init__.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/svtplay_dl/fetcher/hls.py b/lib/svtplay_dl/fetcher/hls.py index 413fcdb..86103dc 100644 --- a/lib/svtplay_dl/fetcher/hls.py +++ b/lib/svtplay_dl/fetcher/hls.py @@ -172,7 +172,7 @@ def _hlsparse(config, text, url, output, **kwargs): for sub in list(subtitles.keys()): for n in subtitles[sub]: m3u8s = M3U8(http.request("get", get_full_url(n[0], url), cookies=cookies).text) - if "cmore" in url or "viaplay" in url: + if "cmore" in url or "viaplay" in url or "dr" in url: subtype = "wrstsegment" else: subtype = "wrst" diff --git a/lib/svtplay_dl/subtitle/__init__.py b/lib/svtplay_dl/subtitle/__init__.py index 7322adf..f0e86f9 100644 --- a/lib/svtplay_dl/subtitle/__init__.py +++ b/lib/svtplay_dl/subtitle/__init__.py @@ -293,6 +293,8 @@ class subtitle: cont.encoding = "utf-8" if "viaplay" in self.url: cont.encoding = "utf-8" + if "dr" in self.url: + cont.encoding = "utf-8" text = cont.text.split("\n") for t in text: # is in text[1] for tv4play, but this should be more future proof if "X-TIMESTAMP-MAP=MPEGTS" in t: @@ -341,6 +343,7 @@ class subtitle: string += "{}\n{}\n\n".format(nr, "\n".join(sub)) nr += 1 + string = re.sub("\r", "", string) return string def stpp(self, subdata):