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

Tv4play: support for the new site

fixes: #1058
This commit is contained in:
Johan Andersson 2019-04-08 23:24:07 +02:00
parent 60c043da62
commit be21f7d695

View File

@ -36,36 +36,27 @@ class Tv4play(Service, OpenGraphThumbMixin):
return return
jansson = json.loads(match.group(1)) jansson = json.loads(match.group(1))
vid = None if "assetId" not in jansson["props"]["pageProps"]:
for i in jansson: yield ServiceError("Cant find video id for the video")
janson2 = json.loads(i["data"]) return
json.dumps(janson2)
if "videoAsset" in janson2["data"]: vid = jansson["props"]["pageProps"]["assetId"]
vid = janson2["data"]["videoAsset"]["id"] janson2 = jansson["props"]["apolloState"]
if janson2["data"]["videoAsset"]["is_drm_protected"]: item = janson2["VideoAsset:{}".format(vid)]
yield ServiceError("We can't download DRM protected content from this site.")
return if item["is_drm_protected"]:
if janson2["data"]["videoAsset"]["is_live"]: yield ServiceError("We can't download DRM protected content from this site.")
self.config.set("live", True) return
if janson2["data"]["videoAsset"]["season"] > 0:
self.output["season"] = janson2["data"]["videoAsset"]["season"] if item["live"]:
if janson2["data"]["videoAsset"]["episode"] > 0: self.config.set("live", True)
self.output["episode"] = janson2["data"]["videoAsset"]["episode"] if item["season"] > 0:
self.output["title"] = janson2["data"]["videoAsset"]["program"]["name"] self.output["season"] = item["season"]
self.output["episodename"] = janson2["data"]["videoAsset"]["title"] if item["episode"] > 0:
vid = str(vid) self.output["episode"] = item["episode"]
self.output["id"] = str(vid) self.output["title"] = item["program_nid"]
if "program" in janson2["data"] and vid is None: self.output["episodename"] = item["title"]
if "contentfulPanels" in janson2["data"]["program"]: self.output["id"] = str(vid)
match = re.search(r"[\/-](\d+)$", self.url)
if match and "panels" in janson2["data"]["program"]:
for n in janson2["data"]["program"]["panels"]:
for z in n["videoList"]["videoAssets"]:
if z["id"] == int(match.group(1)):
vid = z["id"]
self.output["id"] = str(vid)
self.output["episodename"] = z["title"]
self.output["title"] = z["program"]["name"]
if vid is None: if vid is None:
yield ServiceError("Cant find video id for the video") yield ServiceError("Cant find video id for the video")
@ -83,7 +74,7 @@ class Tv4play(Service, OpenGraphThumbMixin):
yield streams[n] yield streams[n]
def _getjson(self): def _getjson(self):
match = re.search(r".prefetched = (\[.*\]);", self.get_urldata()) match = re.search(r"application\/json\">(.*\}\})<\/script><script ", self.get_urldata())
return match return match
def find_all_episodes(self, config): def find_all_episodes(self, config):
@ -92,19 +83,15 @@ class Tv4play(Service, OpenGraphThumbMixin):
show = None show = None
match = self._getjson() match = self._getjson()
jansson = json.loads(match.group(1)) jansson = json.loads(match.group(1))
for i in jansson: janson2 = jansson["props"]["apolloState"]
janson2 = json.loads(i["data"]) for i in janson2:
if "program" in janson2["data"]: if "VideoAsset:" in i:
if "programPanels" in janson2["data"]["program"]: if janson2[i]["clip"] and config.get("include_clips"):
for n in janson2["data"]["program"]["programPanels"]["panels"]: show = janson2[i]["program_nid"]
if n.get("assetType", None) == "EPISODE": items.append(janson2[i]["id"])
for z in n["videoList"]["videoAssets"]: elif janson2[i]["clip"] is False:
show = z["program_nid"] show = janson2[i]["program_nid"]
items.append(z["id"]) items.append(janson2[i]["id"])
if n.get("assetType", None) == "CLIP" and config.get("include_clips"):
for z in n["videoList"]["videoAssets"]:
show = z["program_nid"]
items.append(z["id"])
items = sorted(items) items = sorted(items)
for item in items: for item in items: