From dcf0e6fa702df782c82dd7271aef93d17188b645 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sun, 9 May 2021 21:52:46 +0200 Subject: [PATCH] viafree: handle multiple subs better --- lib/svtplay_dl/service/viaplay.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/svtplay_dl/service/viaplay.py b/lib/svtplay_dl/service/viaplay.py index 31092fc..011ccce 100644 --- a/lib/svtplay_dl/service/viaplay.py +++ b/lib/svtplay_dl/service/viaplay.py @@ -72,8 +72,6 @@ class Viaplay(Service, OpenGraphThumbMixin): output=copy.copy(self.output), m3u8=m3u8s, ) - else: - yield subtitle(copy.copy(self.config), "wrst", video["_embedded"]["program"]["subtitles"]["subtitlesWebvtt"], output=self.output) res = self.http.get(video["_embedded"]["program"]["_links"]["streamLink"]["href"]) janson = res.json() @@ -98,15 +96,22 @@ class Viaplay(Service, OpenGraphThumbMixin): if not self.config.get("get_all_subtitles"): if not language: - yield subtitle(copy.copy(self.config), "wrst", janson["embedded"]["subtitles"][0]["link"]["href"], output=self.output) + yield subtitle(copy.deepcopy(self.config), "wrst", janson["embedded"]["subtitles"][0]["link"]["href"], output=self.output) else: for i in janson["embedded"]["subtitles"]: - if i["data"]["language"] == language: - yield subtitle(copy.copy(self.config), "wrst", i["link"]["href"], output=self.output) + if i["data"]["language"] == language and i["data"]["sdh"] is False: + yield subtitle(copy.deepcopy(self.config), "wrst", i["link"]["href"], output=self.output) else: + substitles = {} for i in janson["embedded"]["subtitles"]: - yield subtitle(copy.copy(self.config), "wrst", i["link"]["href"], i["data"]["language"], output=copy.copy(self.output)) + substitles[(i["data"]["language"], i["data"]["sdh"])] = i["link"]["href"] + + for i in substitles: + lang, shd = i + if shd: + lang = f"{lang}-shd" + yield subtitle(copy.deepcopy(self.config), "wrst", substitles[i], lang, output=copy.copy(self.output)) def find_all_episodes(self, config): episodes = []