aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornixxo <nixxo@protonmail.com>2024-02-16 01:20:58 +0100
committerGitHub <noreply@github.com>2024-02-16 00:20:58 +0000
commitf78814923748277e7067b796f25870686fb46205 (patch)
treeb4d4af0037896edafe10f11da15f102c022cf734
parent017adb28e7fe7b8c8fc472332d86740f31141519 (diff)
[ie/rai] Filter unavailable formats (#9189)
Closes #9154 Authored by: nixxo
-rw-r--r--yt_dlp/extractor/rai.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/yt_dlp/extractor/rai.py b/yt_dlp/extractor/rai.py
index df4102a40..f6219c2db 100644
--- a/yt_dlp/extractor/rai.py
+++ b/yt_dlp/extractor/rai.py
@@ -1,6 +1,7 @@
import re
from .common import InfoExtractor
+from ..networking import HEADRequest
from ..utils import (
clean_html,
determine_ext,
@@ -91,7 +92,7 @@ class RaiBaseIE(InfoExtractor):
self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
if not audio_only and not is_live:
- formats.extend(self._create_http_urls(media_url, relinker_url, formats))
+ formats.extend(self._create_http_urls(media_url, relinker_url, formats, video_id))
return filter_dict({
'is_live': is_live,
@@ -99,7 +100,7 @@ class RaiBaseIE(InfoExtractor):
'formats': formats,
})
- def _create_http_urls(self, manifest_url, relinker_url, fmts):
+ def _create_http_urls(self, manifest_url, relinker_url, fmts, video_id):
_MANIFEST_REG = r'/(?P<id>\w+)(?:_(?P<quality>[\d\,]+))?(?:\.mp4)?(?:\.csmil)?/playlist\.m3u8'
_MP4_TMPL = '%s&overrideUserAgentRule=mp4-%s'
_QUALITY = {
@@ -166,6 +167,14 @@ class RaiBaseIE(InfoExtractor):
'fps': 25,
}
+ # Check if MP4 download is available
+ try:
+ self._request_webpage(
+ HEADRequest(_MP4_TMPL % (relinker_url, '*')), video_id, 'Checking MP4 availability')
+ except ExtractorError as e:
+ self.to_screen(f'{video_id}: MP4 direct download is not available: {e.cause}')
+ return []
+
# filter out single-stream formats
fmts = [f for f in fmts
if not f.get('vcodec') == 'none' and not f.get('acodec') == 'none']