]> jfr.im git - yt-dlp.git/commitdiff
[hls] Warn user when trying to download live HLS
authorpukkandan <redacted>
Sat, 25 Jun 2022 22:40:04 +0000 (04:10 +0530)
committerpukkandan <redacted>
Sat, 25 Jun 2022 23:18:41 +0000 (04:48 +0530)
We do not automatically switch to ffmpeg because the detection is not 100% accurate

yt_dlp/downloader/hls.py

index d93d00f123ac4855987bfdf953646602d4e534a9..1e75c5e9c336fb093b6c1015e920ce133ea0ffe9 100644 (file)
@@ -61,12 +61,18 @@ def real_download(self, filename, info_dict):
         s = urlh.read().decode('utf-8', 'ignore')
 
         can_download, message = self.can_download(s, info_dict, self.params.get('allow_unplayable_formats')), None
-        if can_download and not Cryptodome_AES and '#EXT-X-KEY:METHOD=AES-128' in s:
-            if FFmpegFD.available():
+        if can_download:
+            has_ffmpeg = FFmpegFD.available()
+            no_crypto = not Cryptodome_AES and '#EXT-X-KEY:METHOD=AES-128' in s
+            if no_crypto and has_ffmpeg:
                 can_download, message = False, 'The stream has AES-128 encryption and pycryptodomex is not available'
-            else:
+            elif no_crypto:
                 message = ('The stream has AES-128 encryption and neither ffmpeg nor pycryptodomex are available; '
                            'Decryption will be performed natively, but will be extremely slow')
+            elif re.search(r'#EXT-X-MEDIA-SEQUENCE:(?!0$)', s):
+                install_ffmpeg = '' if has_ffmpeg else 'install ffmpeg and '
+                message = ('Live HLS streams are not supported by the native downloader. If this is a livestream, '
+                           f'please {install_ffmpeg}add "--downloader ffmpeg --hls-use-mpegts" to your command')
         if not can_download:
             has_drm = re.search('|'.join([
                 r'#EXT-X-FAXS-CM:',  # Adobe Flash Access