diff --git a/lib/svtplay_dl/service/svt.py b/lib/svtplay_dl/service/svt.py index 1cf0ce4..2dab826 100644 --- a/lib/svtplay_dl/service/svt.py +++ b/lib/svtplay_dl/service/svt.py @@ -9,16 +9,25 @@ class Svt(Svtplay): supported_domains = ['svt.se', 'www.svt.se'] def get(self): - match = re.search("window.svt.nyh.reduxState=({.*});", self.get_urldata()) - if not match: + + data = self.get_urldata() + match = re.search("window.svt.nyh.reduxState=({.*});", data) + match_data_video_id = re.search("data-video-id=\"(.+?)\"", data) + + if match_data_video_id: + id = match_data_video_id.group(1) + + elif match: + janson = json.loads(match.group(1)) + context = janson["appState"]["location"]["context"] + areaData = janson["areaData"]["articles"][context]["media"] + id = areaData[0]["id"] + + else: yield ServiceError("Cant find video info.") return - janson = json.loads(match.group(1)) - context = janson["appState"]["location"]["context"] - areaData = janson["areaData"]["articles"][context]["media"] - - res = self.http.get("http://api.svt.se/videoplayer-api/video/{0}".format(areaData[0]["id"])) + res = self.http.get("http://api.svt.se/videoplayer-api/video/{0}".format(id)) janson = res.json() videos = self._get_video(janson) for i in videos: