mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 21:54:17 +01:00
parent
9536e23619
commit
a639f9a9db
@ -1,3 +1,4 @@
|
|||||||
|
import codecs
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
@ -11,16 +12,24 @@ class Svt(Svtplay):
|
|||||||
supported_domains = ["svt.se", "www.svt.se"]
|
supported_domains = ["svt.se", "www.svt.se"]
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
|
|
||||||
data = self.get_urldata()
|
data = self.get_urldata()
|
||||||
match = re.search("n.reduxState=(.*);", data)
|
match = re.search("n.reduxState=(.*);", data)
|
||||||
|
if not match:
|
||||||
|
match = re.search(r"stateData = JSON.parse\(\"(.*)\"\)\<\/script", data)
|
||||||
if not match:
|
if not match:
|
||||||
yield ServiceError("Cant find video info.")
|
yield ServiceError("Cant find video info.")
|
||||||
return
|
return
|
||||||
|
janson = json.loads(codecs.escape_decode(match.group(1))[0].decode("utf-8"))
|
||||||
|
if janson["recipe"]["content"]["data"]["videoClips"]:
|
||||||
|
vid = janson["recipe"]["content"]["data"]["videoClips"][0]["id"]
|
||||||
|
else:
|
||||||
|
vid = janson["recipe"]["content"]["data"]["videoEpisodes"][0]["id"]
|
||||||
|
res = self.http.get("https://api.svt.se/videoplayer-api/video/{}".format(vid))
|
||||||
|
else:
|
||||||
janson = json.loads(match.group(1))
|
janson = json.loads(match.group(1))
|
||||||
vid = janson["areaData"]["articles"][list(janson["areaData"]["articles"].keys())[0]]["media"][0]["image"]["svtId"]
|
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))
|
res = self.http.get("https://api.svt.se/video/{}".format(vid))
|
||||||
|
|
||||||
janson = res.json()
|
janson = res.json()
|
||||||
if "subtitleReferences" in janson:
|
if "subtitleReferences" in janson:
|
||||||
for i in janson["subtitleReferences"]:
|
for i in janson["subtitleReferences"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user