2016-08-20 14:17:54 +02:00
|
|
|
import json
|
2019-08-25 00:40:39 +02:00
|
|
|
import re
|
2016-08-20 14:17:54 +02:00
|
|
|
|
|
|
|
from svtplay_dl.error import ServiceError
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
|
|
|
from svtplay_dl.service import OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
2016-08-20 14:17:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Viasatsport(Service, OpenGraphThumbMixin):
|
|
|
|
supported_domains_re = ["www.viasatsport.se"]
|
|
|
|
|
|
|
|
def get(self):
|
2019-09-06 22:49:49 +02:00
|
|
|
match = re.search("__STATE__']=({.*});</script><script>window", self.get_urldata())
|
2016-08-20 14:17:54 +02:00
|
|
|
if not match:
|
|
|
|
yield ServiceError("Cant find video info")
|
|
|
|
return
|
|
|
|
|
|
|
|
dataj = json.loads(match.group(1))
|
|
|
|
vid = dataj["dataSources"]["article"][0]["videos"][0]["data"]["mediaGuid"]
|
|
|
|
|
2021-02-28 22:05:15 +01:00
|
|
|
url = f"https://viasport.mtg-api.com/stream-links/viasport/web/se/clear-media-guids/{vid}/streams"
|
2016-08-20 14:17:54 +02:00
|
|
|
data = self.http.get(url)
|
|
|
|
dataj = data.json()
|
|
|
|
hls = dataj["embedded"]["prioritizedStreams"][0]["links"]["stream"]["href"]
|
2016-08-20 15:15:25 +02:00
|
|
|
if re.search("/live/", hls):
|
2018-05-13 13:06:45 +02:00
|
|
|
self.config.set("live", True)
|
2021-05-16 02:22:37 +02:00
|
|
|
yield from hlsparse(self.config, self.http.request("get", hls), hls, output=self.output)
|