diff --git a/test/test_sabr/test_processor.py b/test/test_sabr/test_processor.py index 7e6a8292d6..ff8eda1e24 100644 --- a/test/test_sabr/test_processor.py +++ b/test/test_sabr/test_processor.py @@ -271,6 +271,11 @@ def test_start_time_ms_invalid(self, base_args, invalid_start_time_ms): start_time_ms=invalid_start_time_ms, ) + def test_client_abr_state_defaults(self, base_args): + processor = SabrProcessor(**base_args) + # Must be enabled to allow DRC formats to be streamed + assert processor.client_abr_state.drc_enabled is True + @pytest.mark.parametrize( 'duration_sec,tolerance_ms', [ diff --git a/yt_dlp/extractor/youtube/_proto/videostreaming/client_abr_state.py b/yt_dlp/extractor/youtube/_proto/videostreaming/client_abr_state.py index d27f4667e4..5452b7c969 100644 --- a/yt_dlp/extractor/youtube/_proto/videostreaming/client_abr_state.py +++ b/yt_dlp/extractor/youtube/_proto/videostreaming/client_abr_state.py @@ -7,3 +7,4 @@ class ClientAbrState: player_time_ms: protobug.Int64 | None = protobug.field(28, default=None) enabled_track_types_bitfield: protobug.Int32 | None = protobug.field(40, default=None) + drc_enabled: protobug.Bool = protobug.field(46, default=False) diff --git a/yt_dlp/extractor/youtube/_streaming/sabr/processor.py b/yt_dlp/extractor/youtube/_streaming/sabr/processor.py index 69aae6de2f..28b04a8879 100644 --- a/yt_dlp/extractor/youtube/_streaming/sabr/processor.py +++ b/yt_dlp/extractor/youtube/_streaming/sabr/processor.py @@ -182,7 +182,9 @@ def _initialize_cabr_state(self): self.logger.debug(f'Starting playback at: {self.start_time_ms}ms') self.client_abr_state = ClientAbrState( player_time_ms=self.start_time_ms, - enabled_track_types_bitfield=enabled_track_types_bitfield) + enabled_track_types_bitfield=enabled_track_types_bitfield, + drc_enabled=True, # Required to stream DRC formats + ) def match_format_selector(self, format_init_metadata): for format_selector in (self._video_format_selector, self._audio_format_selector, self._caption_format_selector): diff --git a/yt_dlp/extractor/youtube/_streaming/sabr/stream.py b/yt_dlp/extractor/youtube/_streaming/sabr/stream.py index d2ccd0fc4b..8f1f86ec16 100644 --- a/yt_dlp/extractor/youtube/_streaming/sabr/stream.py +++ b/yt_dlp/extractor/youtube/_streaming/sabr/stream.py @@ -188,7 +188,7 @@ def url(self): @url.setter def url(self, url): self.logger.debug(f'New URL: {url}') - if hasattr(self, '_url') and ((bn := broadcast_id_from_url(url)) != (bc := broadcast_id_from_url(self.url))): + if self.processor.is_live and hasattr(self, '_url') and ((bn := broadcast_id_from_url(url)) != (bc := broadcast_id_from_url(self.url))): raise SabrStreamError(f'Broadcast ID changed from {bc} to {bn}. The download will need to be restarted.') self._url = url if str_or_none(parse_qs(url).get('source', [None])[0]) == 'yt_live_broadcast':