From c4540927beb61fb07b0d1ae0424d64dc74bdd5d0 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Mon, 18 Oct 2021 16:23:59 +0200 Subject: [PATCH] viafree: use same json grab --- lib/svtplay_dl/service/viaplay.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/svtplay_dl/service/viaplay.py b/lib/svtplay_dl/service/viaplay.py index ea2bc3f..9a19eef 100644 --- a/lib/svtplay_dl/service/viaplay.py +++ b/lib/svtplay_dl/service/viaplay.py @@ -49,7 +49,7 @@ class Viafree(Service, OpenGraphThumbMixin): if not match: yield ServiceError("Cant find necessary info") return - janson = json.loads("{}{}".format("{", match.group(1).replace("undefined", "null"))) + janson = self._jansonpage(match.group(1)) video = None for play in janson["page"]["blocks"]: if "componentName" in play and play["componentName"] == "player": @@ -127,7 +127,7 @@ class Viafree(Service, OpenGraphThumbMixin): logging.error("Cant find necessary info") return - janson = json.loads("{}{}".format("{", match.group(1))) + janson = self._jansonpage(match.group(1)) seasons = [] if janson["page"]["pageType"] == "player": @@ -138,7 +138,7 @@ class Viafree(Service, OpenGraphThumbMixin): logging.error("Cant find necessary info") return - janson = json.loads("{}{}".format("{", match.group(1))) + janson = self._jansonpage(match.group(1)) for i in janson["page"]["blocks"]: if i["slug"] == "series_header" and "seasons" in i["seriesHeader"]: @@ -219,3 +219,6 @@ class Viafree(Service, OpenGraphThumbMixin): self.token = res.json()["data"]["accessToken"] return True return False + + def _jansonpage(text): + return json.loads("{}{}".format("{", text.replace("undefined", "null")))