From 6a09bcde7c96528543d6c7f161924477544cae2f Mon Sep 17 00:00:00 2001 From: Glenn Slayden <5589855+glenn-slayden@users.noreply.github.com> Date: Tue, 6 Jul 2021 14:02:30 -0700 Subject: [PATCH] Early extraction of duration metadata via playlist thumbnail overlay Early gathering of item video durations from playlist metadata, prior to downloading individual item metadata pages, so that video duration values are (e.g.) shown in `--flat-playlist` or `--simulate`, and/or can be used as a download filtering criterion. --- youtube_dl/extractor/youtube.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index dc4bd4a77..7b1560c07 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -316,8 +316,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor): description = try_get( renderer, lambda x: x['descriptionSnippet']['runs'][0]['text'], compat_str) - duration = parse_duration(try_get( - renderer, lambda x: x['lengthText']['simpleText'], compat_str)) + duration_text = try_get( + renderer, + (lambda x: x['lengthText']['simpleText'], + lambda x: x['thumbnailOverlays'][0]['thumbnailOverlayTimeStatusRenderer']['text']['simpleText']), + compat_str) + duration = parse_duration(duration_text) view_count_text = try_get( renderer, lambda x: x['viewCountText']['simpleText'], compat_str) or '' view_count = str_to_int(self._search_regex(