2016-09-02 01:20:54 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2019-08-25 00:40:39 +02:00
|
|
|
import copy
|
|
|
|
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.fetcher.http import HTTP
|
|
|
|
from svtplay_dl.service import OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
2016-09-02 01:20:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Riksdagen(Service, OpenGraphThumbMixin):
|
2018-10-28 16:29:17 +01:00
|
|
|
supported_domains_re = ["riksdagen.se", "www.riksdagen.se"]
|
2016-09-02 01:20:54 +02:00
|
|
|
|
|
|
|
def get(self):
|
2018-10-28 16:29:17 +01:00
|
|
|
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)
|
|
|
|
res = self.http.get("http://www.riksdagen.se/api/videostream/get/%s" % vid)
|
|
|
|
data = res.json()
|
|
|
|
|
|
|
|
try:
|
|
|
|
janson = data["videodata"][0]["streams"]["files"]
|
|
|
|
except TypeError:
|
|
|
|
yield ServiceError("Cant find video.")
|
|
|
|
return
|
|
|
|
|
|
|
|
for i in janson:
|
|
|
|
if i["mimetype"] == "application/x-mpegurl":
|
|
|
|
data2 = self.http.get(i["url"]).json()
|
2019-09-06 22:49:49 +02:00
|
|
|
streams = hlsparse(self.config, self.http.request("get", data2["url"]), data2["url"], output=self.output)
|
2018-05-08 22:48:55 +02:00
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield streams[n]
|
2018-10-28 16:29:17 +01:00
|
|
|
if i["mimetype"] == "video/mp4":
|
|
|
|
for n in i["bandwidth"]:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield HTTP(copy.copy(self.config), n["url"], n["quality"], output=self.output)
|