diff options
author | coletdjnz <coletdjnz@protonmail.com> | 2023-03-01 07:56:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 07:56:53 +0000 |
commit | 7f51861b1820c37b157a239b1fe30628d907c034 (patch) | |
tree | 56cbf08bdc74443e93037e370c030e4f886b7638 /yt_dlp | |
parent | 5b28cef72db3b531680d89c121631c73ae05354f (diff) | |
download | hypervideo-pre-7f51861b1820c37b157a239b1fe30628d907c034.tar.lz hypervideo-pre-7f51861b1820c37b157a239b1fe30628d907c034.tar.xz hypervideo-pre-7f51861b1820c37b157a239b1fe30628d907c034.zip |
[extractor/youtube] Detect and break on looping comments (#6301)
Fixes https://github.com/yt-dlp/yt-dlp/issues/6290
Authored by: coletdjnz
Diffstat (limited to 'yt_dlp')
-rw-r--r-- | yt_dlp/extractor/youtube.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 44e932293..b02e0153a 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -3341,6 +3341,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor): comment = self._extract_comment(comment_renderer, parent) if not comment: continue + # Sometimes YouTube may break and give us infinite looping comments. + # See: https://github.com/yt-dlp/yt-dlp/issues/6290 + if comment['id'] in tracker['seen_comment_ids']: + self.report_warning('Detected YouTube comments looping. Stopping comment extraction as we probably cannot get any more.') + yield + else: + tracker['seen_comment_ids'].add(comment['id']) tracker['running_total'] += 1 tracker['total_reply_comments' if parent else 'total_parent_comments'] += 1 @@ -3365,7 +3372,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor): est_total=0, current_page_thread=0, total_parent_comments=0, - total_reply_comments=0) + total_reply_comments=0, + seen_comment_ids=set()) # TODO: Deprecated # YouTube comments have a max depth of 2 |