mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-01 15:12:57 +00:00
move continue block, filter() comment_keys for None
This commit is contained in:
parent
4701ad6c2e
commit
6f5c669fcc
|
@ -3453,9 +3453,6 @@ def extract_thread(contents, entity_payloads):
|
|||
expected_type=dict, default={})
|
||||
|
||||
comment = self._extract_comment_old(comment_renderer, parent)
|
||||
if not comment:
|
||||
continue
|
||||
comment_id = comment['id']
|
||||
|
||||
# new comment format
|
||||
else:
|
||||
|
@ -3464,13 +3461,14 @@ def extract_thread(contents, entity_payloads):
|
|||
or traverse_obj(content, ('commentViewModel', {dict})))
|
||||
if not view_model:
|
||||
continue
|
||||
comment_id = view_model['commentId']
|
||||
comment_key = view_model.get('commentKey')
|
||||
toolbar_state_key = view_model.get('toolbarStateKey')
|
||||
entities = traverse_obj(entity_payloads, lambda _, v: v["entityKey"] in [comment_key, toolbar_state_key])
|
||||
|
||||
comment_keys = list(filter(None, [view_model.get('commentKey'), view_model.get('toolbarStateKey')]))
|
||||
entities = traverse_obj(entity_payloads, lambda _, v: v['entityKey'] in comment_keys)
|
||||
comment = self._extract_comment(view_model, entities, parent)
|
||||
|
||||
if not comment:
|
||||
continue
|
||||
comment_id = comment['id']
|
||||
|
||||
if comment.get('is_pinned'):
|
||||
tracker['pinned_comment_ids'].add(comment_id)
|
||||
# Sometimes YouTube may break and give us infinite looping comments.
|
||||
|
|
Loading…
Reference in a new issue