1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-08-14 16:38:29 +00:00

Fix DRC formats failing to download

This commit is contained in:
coletdjnz 2025-08-10 12:59:07 +12:00
parent a37f1de764
commit 993c19dc59
No known key found for this signature in database
GPG Key ID: 91984263BB39894A
4 changed files with 10 additions and 2 deletions

View File

@ -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',
[

View File

@ -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)

View File

@ -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):

View File

@ -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':