diff options
author | coletdjnz <colethedj@protonmail.com> | 2021-10-18 15:58:42 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 02:58:42 +0000 |
commit | aae16f6ed9ba1fc6943a8461d0a9aa8be6e5561d (patch) | |
tree | ae6236f861df0cee822f922ff1a7cb6c96620e67 | |
parent | 373475f03553a7fff2d20df878755bfad2fab8e5 (diff) | |
download | hypervideo-pre-aae16f6ed9ba1fc6943a8461d0a9aa8be6e5561d.tar.lz hypervideo-pre-aae16f6ed9ba1fc6943a8461d0a9aa8be6e5561d.tar.xz hypervideo-pre-aae16f6ed9ba1fc6943a8461d0a9aa8be6e5561d.zip |
[youtube:comments] Fix comment section not being extracted in new layouts (#1324)
Co-authored-by: coletdjnz, pukkandan
-rw-r--r-- | yt_dlp/extractor/youtube.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index dc9aa8ab7..892993c9b 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -2314,6 +2314,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor): continuation_token = self._generate_comment_continuation(video_id) continuation = self._build_api_continuation_query(continuation_token, None) + message = self._get_text(root_continuation_data, ('contents', ..., 'messageRenderer', 'text'), max_runs=1) + if message and not parent: + self.report_warning(message, video_id=video_id) + visitor_data = None is_first_continuation = parent is None @@ -2416,8 +2420,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor): def _get_comments(self, ytcfg, video_id, contents, webpage): """Entry for comment extraction""" def _real_comment_extract(contents): - yield from self._comment_entries( - traverse_obj(contents, (..., 'itemSectionRenderer'), get_all=False), ytcfg, video_id) + renderer = next(( + item for item in traverse_obj(contents, (..., 'itemSectionRenderer'), default={}) + if item.get('sectionIdentifier') == 'comment-item-section'), None) + yield from self._comment_entries(renderer, ytcfg, video_id) max_comments = int_or_none(self._configuration_arg('max_comments', [''])[0]) # Force English regardless of account setting to prevent parsing issues |