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

31 lines
959 B
Python
Raw Normal View History

2019-08-25 00:40:39 +02:00
import re
2016-09-02 01:20: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-09-02 01:20:54 +02:00
class Riksdagen(Service, OpenGraphThumbMixin):
supported_domains_re = ["riksdagen.se", "www.riksdagen.se"]
2016-09-02 01:20:54 +02:00
def get(self):
match = re.search("_([a-zA-Z0-9]+)$", self.url)
2016-09-02 01:20:54 +02:00
if not match:
yield ServiceError("Cant find video id.")
return
vid = match.group(1)
2021-12-18 19:52:08 +01:00
res = self.http.get(f"http://www.riksdagen.se/api/videostream/get/{vid}")
2016-09-02 01:20:54 +02:00
data = res.json()
try:
janson = data["videodata"][0]["streams"]["files"]
except TypeError:
yield ServiceError("Cant find video.")
return
for i in janson:
2021-09-12 23:56:16 +02:00
for n in i["bandwidth"]:
yield from hlsparse(self.config, self.http.request("get", n["url"]), n["url"], output=self.output)