From 44a7c656a3ff76357dbd5a1169ab8b19bb4fefd4 Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Fri, 29 Oct 2021 12:02:41 +0200 Subject: [PATCH 1/6] Add livestream.kuleuven.be extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/kuleuven_live.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 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..aff52d6a8 --- /dev/null +++ b/youtube_dl/extractor/kuleuven_live.py @@ -0,0 +1,24 @@ +# 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]+)' + BACKEND_BASE_URL = "https://icts-p-toledo-streaming-video-live-backend.cloud.icts.kuleuven.be/api/viewers/" + + def _real_extract(self, url): + pin = self._match_id(url) + + json_res = self._download_json(self.BACKEND_BASE_URL + pin, pin, 'Requesting stream URL') + 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, + } From 6c75cd3c68c08246d610146a1dbea3a0201a25ce Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Fri, 29 Oct 2021 14:44:59 +0200 Subject: [PATCH 2/6] Experimental override option for output args --- youtube_dl/__init__.py | 4 ++++ youtube_dl/downloader/external.py | 5 ++++- youtube_dl/options.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index e1bd67919..ac3b18978 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -310,6 +310,9 @@ def _real_main(argv=None): postprocessor_args = None if opts.postprocessor_args: postprocessor_args = compat_shlex_split(opts.postprocessor_args) + ffmpeg_out_override = None + if opts.ffmpeg_out_override: + ffmpeg_out_override = compat_shlex_split(opts.ffmpeg_out_override) match_filter = ( None if opts.match_filter is None else match_filter_func(opts.match_filter)) @@ -427,6 +430,7 @@ def _real_main(argv=None): 'hls_prefer_native': opts.hls_prefer_native, 'hls_use_mpegts': opts.hls_use_mpegts, 'external_downloader_args': external_downloader_args, + 'ffmpeg_out_override': ffmpeg_out_override, 'postprocessor_args': postprocessor_args, 'cn_verification_proxy': opts.cn_verification_proxy, 'geo_verification_proxy': opts.geo_verification_proxy, diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index c31f8910a..645a68e01 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -311,7 +311,10 @@ class FFmpegFD(ExternalFD): elif isinstance(conn, compat_str): args += ['-rtmp_conn', conn] - args += ['-i', url, '-c', 'copy'] + args += ['-i', url] + + ffmpeg_out_override = self.params.get('ffmpeg_out_override') + args += ffmpeg_out_override if ffmpeg_out_override else ['-c', 'copy'] if self.params.get('test', False): args += ['-fs', compat_str(self._TEST_FILE_SIZE)] diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 0a0641bd4..35aa2ba41 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -525,6 +525,10 @@ def parseOpts(overrideArguments=None): '--external-downloader-args', dest='external_downloader_args', metavar='ARGS', help='Give these arguments to the external downloader') + downloader.add_option( + '--ffmpeg-out-override', + dest='ffmpeg_out_override', metavar='ARGS', + help='Give these arguments to the ffmpeg instead of `-c copy`') workarounds = optparse.OptionGroup(parser, 'Workarounds') workarounds.add_option( From c2d325eafd025652ee999d33e14065e67fac7544 Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Fri, 29 Oct 2021 12:02:41 +0200 Subject: [PATCH 3/6] [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, + } From bea7488c6f46819be3bd25a235f35527e9f97cf8 Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Fri, 29 Oct 2021 14:44:59 +0200 Subject: [PATCH 4/6] [downloader/ffmpeg] Add override option for FFmpeg output args --- youtube_dl/__init__.py | 4 ++++ youtube_dl/downloader/external.py | 5 ++++- youtube_dl/options.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index e1bd67919..ac3b18978 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -310,6 +310,9 @@ def _real_main(argv=None): postprocessor_args = None if opts.postprocessor_args: postprocessor_args = compat_shlex_split(opts.postprocessor_args) + ffmpeg_out_override = None + if opts.ffmpeg_out_override: + ffmpeg_out_override = compat_shlex_split(opts.ffmpeg_out_override) match_filter = ( None if opts.match_filter is None else match_filter_func(opts.match_filter)) @@ -427,6 +430,7 @@ def _real_main(argv=None): 'hls_prefer_native': opts.hls_prefer_native, 'hls_use_mpegts': opts.hls_use_mpegts, 'external_downloader_args': external_downloader_args, + 'ffmpeg_out_override': ffmpeg_out_override, 'postprocessor_args': postprocessor_args, 'cn_verification_proxy': opts.cn_verification_proxy, 'geo_verification_proxy': opts.geo_verification_proxy, diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index c31f8910a..645a68e01 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -311,7 +311,10 @@ class FFmpegFD(ExternalFD): elif isinstance(conn, compat_str): args += ['-rtmp_conn', conn] - args += ['-i', url, '-c', 'copy'] + args += ['-i', url] + + ffmpeg_out_override = self.params.get('ffmpeg_out_override') + args += ffmpeg_out_override if ffmpeg_out_override else ['-c', 'copy'] if self.params.get('test', False): args += ['-fs', compat_str(self._TEST_FILE_SIZE)] diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 0a0641bd4..35aa2ba41 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -525,6 +525,10 @@ def parseOpts(overrideArguments=None): '--external-downloader-args', dest='external_downloader_args', metavar='ARGS', help='Give these arguments to the external downloader') + downloader.add_option( + '--ffmpeg-out-override', + dest='ffmpeg_out_override', metavar='ARGS', + help='Give these arguments to the ffmpeg instead of `-c copy`') workarounds = optparse.OptionGroup(parser, 'Workarounds') workarounds.add_option( From 433f671ee084e6973988650757879db917a3b8e5 Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Tue, 22 Mar 2022 13:30:46 +0100 Subject: [PATCH 5/6] Update readme and supported sites --- README.md | 2 ++ docs/supportedsites.md | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2841ed68f..aac5d49c1 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo url,ffmpeg,httpie,wget --external-downloader-args ARGS Give these arguments to the external downloader + --ffmpeg-out-override ARGS Give these arguments to the ffmpeg + instead of `-c copy` ## Filesystem Options: -a, --batch-file FILE File containing URLs to download ('-' diff --git a/docs/supportedsites.md b/docs/supportedsites.md index ed0d5e9d9..28f66fb92 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -433,6 +433,7 @@ - **KonserthusetPlay** - **KrasView**: Красвью - **Ku6** + - **KULLive** - **KUSI** - **kuwo:album**: 酷我音乐 - 专辑 - **kuwo:category**: 酷我音乐 - 分类 @@ -472,8 +473,6 @@ - **LinuxAcademy** - **LiTV** - **LiveJournal** - - **LiveLeak** - - **LiveLeakEmbed** - **livestream** - **livestream:original** - **LnkGo** From 5283ae43ad169776360b86f59699ec96bfc15f49 Mon Sep 17 00:00:00 2001 From: Inias Peeters Date: Mon, 28 Mar 2022 16:14:05 +0200 Subject: [PATCH 6/6] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aac5d49c1..b488e735e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -[![Build Status](https://github.com/ytdl-org/youtube-dl/workflows/CI/badge.svg)](https://github.com/ytdl-org/youtube-dl/actions?query=workflow%3ACI) +# In this fork +This fork adds an extractor for recording lectures from a https://livestream.kuleuven.be/ stream. + +# youtube-dl youtube-dl - download videos from youtube.com or other video platforms