From 916e19996c3fac06802cdf26d2c82e017e5b39f6 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Tue, 2 Jun 2020 17:41:30 +0200 Subject: [PATCH] svt: fix so we can download videos again --- lib/svtplay_dl/service/svt.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/svtplay_dl/service/svt.py b/lib/svtplay_dl/service/svt.py index 3c0bb93..7326237 100644 --- a/lib/svtplay_dl/service/svt.py +++ b/lib/svtplay_dl/service/svt.py @@ -1,4 +1,5 @@ import copy +import json import re from svtplay_dl.error import ServiceError @@ -12,16 +13,14 @@ class Svt(Svtplay): def get(self): data = self.get_urldata() - match_data_video_id = re.search('data-video-id="(.+?)"', data) - - if match_data_video_id: - id = match_data_video_id.group(1) - - else: + match = re.search("n.reduxState=(.*);", data) + if not match: yield ServiceError("Cant find video info.") return - res = self.http.get("http://api.svt.se/videoplayer-api/video/{}".format(id)) + janson = json.loads(match.group(1)) + vid = janson["areaData"]["articles"][list(janson["areaData"]["articles"].keys())[0]]["media"][0]["image"]["svtId"] + res = self.http.get("https://api.svt.se/video/{}".format(vid)) janson = res.json() if "subtitleReferences" in janson: for i in janson["subtitleReferences"]: