From: Lomanic <lomanic@hotmail.fr>
---
extractors/video.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/extractors/video.py b/extractors/video.py
index fe23de7..dfbde0e 100644
--- a/extractors/video.py
@@ -219,7 +219,12 @@ def get_more_stuff_from_file(id, result):
yt_initial_data = extract_yt_initial_data(content)
- main_video = yt_initial_data["contents"]["twoColumnWatchNextResults"]["results"]["results"]["contents"][0]["videoPrimaryInfoRenderer"]
+ # for some topics like COVID, the first "contents" element is not the one we are interested in
+ # but an "Information panel giving topical context" https://support.google.com/youtube/answer/9004474
+ for c in yt_initial_data["contents"]["twoColumnWatchNextResults"]["results"]["results"]["contents"]:
+ if c.get("videoPrimaryInfoRenderer", False):
+ main_video = c["videoPrimaryInfoRenderer"]
+
views = main_video["viewCount"]["videoViewCountRenderer"]
result["second__viewCountText"] = get_view_count_text_or_recommended(views)
if "shortViewCount" in views:
--
2.32.0