From 2bbe273a81b76d9ddd4df8bac7372db6ec1666a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 29 Aug 2022 22:09:59 +0200 Subject: [PATCH] [youtube] add published_time for --flat_playlist JSON It is very desirable to have information about video age too. Example: youtube-dl --flat-playlist -j ytsearch10:"egg recipe" --- youtube_dl/extractor/youtube.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 3d12e2e4a..46db7b666 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -330,6 +330,8 @@ class YoutubeBaseInfoExtractor(InfoExtractor): renderer, (lambda x: x['ownerText']['runs'][0]['text'], lambda x: x['shortBylineText']['runs'][0]['text']), compat_str) + published_time = try_get( + renderer, lambda x: x['publishedTimeText']['simpleText'], compat_str) or '' return { '_type': 'url', 'ie_key': YoutubeIE.ie_key(), @@ -340,6 +342,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor): 'duration': duration, 'view_count': view_count, 'uploader': uploader, + 'published_time': published_time, } def _search_results(self, query, params):