]> jfr.im git - yt-dlp.git/commitdiff
[dash] Show fragment count with `--live-from-start` (#3493)
authorMMM <redacted>
Tue, 7 Jun 2022 12:44:08 +0000 (14:44 +0200)
committerGitHub <redacted>
Tue, 7 Jun 2022 12:44:08 +0000 (05:44 -0700)
Authored by: flashdagger

yt_dlp/downloader/dash.py
yt_dlp/downloader/fragment.py
yt_dlp/extractor/youtube.py

index d0a0b28934721d0cab6cf2cd97452465255f0956..a6da26f09de94ddcc9929740a2650062bf747adb 100644 (file)
@@ -73,6 +73,7 @@ def _get_fragments(self, fmt, ctx):
 
             yield {
                 'frag_index': frag_index,
+                'fragment_count': fragment.get('fragment_count'),
                 'index': i,
                 'url': fragment_url,
             }
index d94cb49569393bc6b6ef2e04d1fcce118ce96246..79161b8092d32f8e09adef2c1396ecd2a5f63e50 100644 (file)
@@ -242,6 +242,9 @@ def frag_progress_hook(s):
             if s['status'] not in ('downloading', 'finished'):
                 return
 
+            if not total_frags and ctx.get('fragment_count'):
+                state['fragment_count'] = ctx['fragment_count']
+
             if ctx_id is not None and s.get('ctx_id') != ctx_id:
                 return
 
@@ -450,6 +453,7 @@ def download_fragment(fragment, ctx):
             fatal, count = is_fatal(fragment.get('index') or (frag_index - 1)), 0
             while count <= fragment_retries:
                 try:
+                    ctx['fragment_count'] = fragment.get('fragment_count')
                     if self._download_fragment(ctx, fragment['url'], info_dict, headers):
                         break
                     return
index 113b9aa07acedbd79068b557c93bb9804fd9fdf1..d44f16bc0b1aa2a50d4abc9a7b366586301c7e98 100644 (file)
@@ -2407,6 +2407,7 @@ def _extract_sequence_from_mpd(refresh_sequence, immediate):
                     last_segment_url = urljoin(fragment_base_url, 'sq/%d' % idx)
                     yield {
                         'url': last_segment_url,
+                        'fragment_count': last_seq,
                     }
                 if known_idx == last_seq:
                     no_fragment_score += 5