1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

viafree: use same json grab

This commit is contained in:
Johan Andersson 2021-10-18 16:23:59 +02:00
parent 163df0ea14
commit c4540927be

View File

@ -49,7 +49,7 @@ class Viafree(Service, OpenGraphThumbMixin):
if not match: if not match:
yield ServiceError("Cant find necessary info") yield ServiceError("Cant find necessary info")
return return
janson = json.loads("{}{}".format("{", match.group(1).replace("undefined", "null"))) janson = self._jansonpage(match.group(1))
video = None video = None
for play in janson["page"]["blocks"]: for play in janson["page"]["blocks"]:
if "componentName" in play and play["componentName"] == "player": if "componentName" in play and play["componentName"] == "player":
@ -127,7 +127,7 @@ class Viafree(Service, OpenGraphThumbMixin):
logging.error("Cant find necessary info") logging.error("Cant find necessary info")
return return
janson = json.loads("{}{}".format("{", match.group(1))) janson = self._jansonpage(match.group(1))
seasons = [] seasons = []
if janson["page"]["pageType"] == "player": if janson["page"]["pageType"] == "player":
@ -138,7 +138,7 @@ class Viafree(Service, OpenGraphThumbMixin):
logging.error("Cant find necessary info") logging.error("Cant find necessary info")
return return
janson = json.loads("{}{}".format("{", match.group(1))) janson = self._jansonpage(match.group(1))
for i in janson["page"]["blocks"]: for i in janson["page"]["blocks"]:
if i["slug"] == "series_header" and "seasons" in i["seriesHeader"]: if i["slug"] == "series_header" and "seasons" in i["seriesHeader"]:
@ -219,3 +219,6 @@ class Viafree(Service, OpenGraphThumbMixin):
self.token = res.json()["data"]["accessToken"] self.token = res.json()["data"]["accessToken"]
return True return True
return False return False
def _jansonpage(text):
return json.loads("{}{}".format("{", text.replace("undefined", "null")))