extract_items: Handle case where continuation has multiple

[something]Continuation renderers, all of which are junk
except one. Check the items in each one until the one which
contains the items being sought is found.
The usage in extract_comments_info needed to be changed to
specify the items being sought. It was unspecified before which
is strictly incorrect since extract_items by default looks for
video/playlist/channel thumbnail items. It was relying on this
special case for continuations. But now that wouldn't work
anymore.
This commit is contained in:
James Taylor
2020-08-11 19:59:25 -07:00
parent 81ff5ab99c
commit fa61874f97
2 changed files with 23 additions and 11 deletions

View File

@@ -227,7 +227,8 @@ def extract_comments_info(polymer_json):
info['sort'] = metadata.get('sort')
info['video_title'] = None
comments, ctoken = extract_items(response)
comments, ctoken = extract_items(response,
item_types={'commentThreadRenderer', 'commentRenderer'})
info['comments'] = []
info['ctoken'] = ctoken
for comment in comments: