1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 15:14:14 +01:00

First version of an extractor for regeringen.se

This commit is contained in:
Pierre Mesure 2024-03-19 07:04:48 +01:00 committed by Johan Andersson
parent 5069e87fbe
commit bffb6d04bb
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,36 @@
import html
import re
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.service import Service
class Regeringen(Service):
supported_domains_re = ["regeringen.se", "www.regeringen.se"]
def get(self):
res = self.http.get(self.url)
html_data = res.text
match = re.search(r"<title>(.*?) -", html_data)
if match:
self.output["title"] = html.unescape(match.group(1))
match = re.search(r"//video.qbrick.com/api/v1/(.*?)'", html_data)
if match:
result = match.group(1)
else:
yield ServiceError("Cant find the video.")
data_url = f"https://video.qbrick.com/api/v1/{result}"
res = self.http.get(data_url)
data = res.json()
resources = data["asset"]["resources"]
index_resources = [resource for resource in resources if resource["type"] == "index"]
links = index_resources[0]["renditions"][0]["links"]
hls_url = [link for link in links if "x-mpegURL" in link["mimeType"]][0]["href"]
if hls_url.find(".m3u8") > 0:
yield from hlsparse(self.config, self.http.request("get", hls_url), hls_url, output=self.output)

View File

@ -25,6 +25,7 @@ from svtplay_dl.service.plutotv import Plutotv
from svtplay_dl.service.pokemon import Pokemon from svtplay_dl.service.pokemon import Pokemon
from svtplay_dl.service.radioplay import Radioplay from svtplay_dl.service.radioplay import Radioplay
from svtplay_dl.service.raw import Raw from svtplay_dl.service.raw import Raw
from svtplay_dl.service.regeringen import Regeringen
from svtplay_dl.service.riksdagen import Riksdagen from svtplay_dl.service.riksdagen import Riksdagen
from svtplay_dl.service.ruv import Ruv from svtplay_dl.service.ruv import Ruv
from svtplay_dl.service.solidtango import Solidtango from svtplay_dl.service.solidtango import Solidtango
@ -84,6 +85,7 @@ sites = [
Vimeo, Vimeo,
Vg, Vg,
Youplay, Youplay,
Regeringen,
Riksdagen, Riksdagen,
Raw, Raw,
] ]