From 3a80322239eca1951de7d1aa39c507f8fbbaadaf Mon Sep 17 00:00:00 2001 From: doe1080 <98906116+doe1080@users.noreply.github.com> Date: Tue, 1 Dec 2026 10:41:34 +0900 Subject: [PATCH] [ie] Fix parsing of ISM timestamp and duration (#17862) Authored by: doe1080 --- yt_dlp/extractor/common.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 2dd703617e..55e77581d3 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -3247,6 +3247,7 @@ class InfoExtractor: continue url_pattern = stream.attrib['Url'] stream_timescale = int_or_none(stream.get('TimeScale')) or timescale + stream_duration = duration * stream_timescale // timescale stream_name = stream.get('Name') # IsmFD expects ISO 639 Set 2 language codes (3-character length) # See: https://github.com/yt-dlp/yt-dlp/issues/11356 @@ -3282,10 +3283,10 @@ class InfoExtractor: fragment_ctx['duration'] = int_or_none(stream_fragment.get('d')) if not fragment_ctx['duration']: try: - next_fragment_time = int(stream_fragment[stream_fragment_index + 1].attrib['t']) + next_fragment_time = int(stream_fragments[stream_fragment_index + 1].attrib['t']) except IndexError: - next_fragment_time = duration - fragment_ctx['duration'] = (next_fragment_time - fragment_ctx['time']) / fragment_repeat + next_fragment_time = stream_duration + fragment_ctx['duration'] = (next_fragment_time - fragment_ctx['time']) // fragment_repeat for _ in range(fragment_repeat): fragments.append({ 'url': re.sub(r'{start[ _]time}', str(fragment_ctx['time']), track_url_pattern), @@ -3302,7 +3303,7 @@ class InfoExtractor: 'fragments': fragments, '_download_params': { 'stream_type': stream_type, - 'duration': duration, + 'duration': stream_duration, 'timescale': stream_timescale, 'fourcc': fourcc, 'language': stream_language, @@ -3328,7 +3329,7 @@ class InfoExtractor: 'audio_channels': int_or_none(track.get('Channels')), '_download_params': { 'stream_type': stream_type, - 'duration': duration, + 'duration': stream_duration, 'timescale': stream_timescale, 'width': width or 0, 'height': height or 0,