Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rai] fix #9154 #9189

Merged
merged 2 commits into from Feb 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions 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,
Expand Down Expand Up @@ -91,15 +92,15 @@ def fix_cdata(s):
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,
'duration': duration,
'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 = {
Expand Down Expand Up @@ -166,6 +167,14 @@ def get_format_info(tbr):
'fps': 25,
}

# Check if MP4 download is available
bashonly marked this conversation as resolved.
Show resolved Hide resolved
try:
self._request_webpage(
HEADRequest(_MP4_TMPL % (relinker_url, '*')), video_id=video_id, note='Checking MP4 availability')
bashonly marked this conversation as resolved.
Show resolved Hide resolved
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']
Expand Down