1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-23 19:55:38 +01:00

tv4play: add support for dash streams

This commit is contained in:
Johan Andersson 2021-06-04 00:38:49 +02:00
parent 88432ed5ea
commit 9ebb2e9c01

View File

@ -7,6 +7,7 @@ from datetime import timedelta
from urllib.parse import urlparse
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.dash import dashparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.service import OpenGraphThumbMixin
from svtplay_dl.service import Service
@ -70,11 +71,20 @@ class Tv4play(Service, OpenGraphThumbMixin):
if res.status_code > 200:
yield ServiceError("Can't play this because the video is geoblocked or not available.")
return
if res.json()["playbackItem"]["type"] == "hls":
jansson = res.json()
if jansson["playbackItem"]["type"] == "hls":
yield from hlsparse(
self.config,
self.http.request("get", res.json()["playbackItem"]["manifestUrl"]),
res.json()["playbackItem"]["manifestUrl"],
self.http.request("get", jansson["playbackItem"]["manifestUrl"]),
jansson["playbackItem"]["manifestUrl"],
output=self.output,
httpobject=self.http,
)
yield from dashparse(
self.config,
self.http.request("get", jansson["playbackItem"]["manifestUrl"].replace(".m3u8", ".mpd")),
jansson["playbackItem"]["manifestUrl"].replace(".m3u8", ".mpd"),
output=self.output,
httpobject=self.http,
)