From 83af4ab0d7c3b002b451f8c113783982d173bb61 Mon Sep 17 00:00:00 2001 From: Jesus Date: Mon, 11 Sep 2023 04:15:25 +0800 Subject: Fix comment count not extracted sometimes YouTube created a new key 'commentCount' in addition to 'headerText' --- youtube/yt_data_extract/watch_extraction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'youtube/yt_data_extract') diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py index 6090e44..1a926b2 100644 --- a/youtube/yt_data_extract/watch_extraction.py +++ b/youtube/yt_data_extract/watch_extraction.py @@ -357,7 +357,8 @@ def _extract_watch_info_mobile(top_level): # https://www.androidpolice.com/2019/10/31/google-youtube-app-comment-section-below-videos/ # https://www.youtube.com/watch?v=bR5Q-wD-6qo if header_type == 'commentsEntryPointHeaderRenderer': - comment_count_text = extract_str(comment_info.get('headerText')) + comment_count_text = extract_str(multi_get( + comment_info, 'commentCount', 'headerText')) else: comment_count_text = extract_str(deep_get(comment_info, 'header', 'commentSectionHeaderRenderer', 'countText')) -- cgit v1.2.3