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

tv4: update detection

This commit is contained in:
Johan Andersson 2021-09-12 23:36:01 +02:00
parent 8771cde5f6
commit 3e4a36d896

View File

@ -197,24 +197,16 @@ class Tv4(Service, OpenGraphThumbMixin):
supported_domains = ["tv4.se"]
def get(self):
match = re.search(r"[\/-](\d+)$", self.url)
match = re.search(r"application\/json\"\>(\{.*\})\<\/script", self.get_urldata())
if not match:
yield ServiceError("Cant find video id")
yield ServiceError("Can't find video data'")
return
self.output["id"] = match.group(1)
match = re.search("data-program-format='([^']+)'", self.get_urldata())
if not match:
yield ServiceError("Cant find program name")
return
self.output["title"] = match.group(1)
match = re.search('img alt="([^"]+)" class="video-image responsive"', self.get_urldata())
if not match:
yield ServiceError("Cant find title of the video")
return
self.output["episodename"] = match.group(1)
janson = json.loads(match.group(1))
self.output["id"] = janson["query"]["id"]
self.output["title"] = janson["query"]["slug"]
if janson["query"]["type"] == "Article":
vidasset = janson["props"]["pageProps"]["apolloState"][f"Article:{janson['query']['id']}"]["featured"]["__ref"]
self.output["id"] = janson["props"]["pageProps"]["apolloState"][vidasset]["id"]
url = "https://playback-api.b17g.net/media/{}?service=tv4&device=browser&protocol=hls%2Cdash&drm=widevine".format(self.output["id"])
res = self.http.request("get", url, cookies=self.cookies)
if res.status_code > 200: