From c2d325eafd025652ee999d33e14065e67fac7544 Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Fri, 29 Oct 2021 12:02:41 +0200 Subject: [PATCH] [kuleuven_live] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/kuleuven_live.py | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 youtube_dl/extractor/kuleuven_live.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 6e8fc3961..ffdd681e4 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -548,6 +548,7 @@ from .kinopoisk import KinoPoiskIE from .konserthusetplay import KonserthusetPlayIE from .krasview import KrasViewIE from .ku6 import Ku6IE +from .kuleuven_live import KULLiveIE from .kusi import KUSIIE from .kuwo import ( KuwoIE, diff --git a/youtube_dl/extractor/kuleuven_live.py b/youtube_dl/extractor/kuleuven_live.py new file mode 100644 index 000000000..cb4bd1951 --- /dev/null +++ b/youtube_dl/extractor/kuleuven_live.py @@ -0,0 +1,28 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class KULLiveIE(InfoExtractor): + _VALID_URL = r'(?:(?:https?://(?:www\.)?livestream.kuleuven\.be/\?pin=)|kulive:)(?P[0-9]+)' + + def _real_extract(self, url): + pin = self._match_id(url) + + json_res = self._download_json( + "https://icts-p-toledo-streaming-video-live-backend.cloud.icts.kuleuven.be/api/viewers/" + pin, + pin, + 'Requesting stream URL', + errnote='The stream with pin %s does not exist or has not started yet' % pin, + fatal=True) + m3u8_url = json_res['streamUrl'] + + formats = self._extract_m3u8_formats(m3u8_url, pin, 'mp4') + + return { + 'id': pin, + 'title': 'kul-stream', + 'is_live': True, + 'formats': formats, + }