From 65bb7a2c4c10d738ddc1d4876855767755fbb1d0 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Thu, 4 Nov 2021 01:59:50 +1300 Subject: [PATCH] Fix recommended extraction when fact check notice --- extractors/video.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extractors/video.py b/extractors/video.py index fe23de7..c487cb5 100644 --- a/extractors/video.py +++ b/extractors/video.py @@ -219,7 +219,11 @@ 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"] + # result = yt_initial_data + # return result + + main_sections = yt_initial_data["contents"]["twoColumnWatchNextResults"]["results"]["results"]["contents"] + main_video = next(s["videoPrimaryInfoRenderer"] for s in main_sections if "videoPrimaryInfoRenderer" in s) views = main_video["viewCount"]["videoViewCountRenderer"] result["second__viewCountText"] = get_view_count_text_or_recommended(views) if "shortViewCount" in views: @@ -234,9 +238,6 @@ def get_more_stuff_from_file(id, result): recommendations = yt_initial_data["contents"]["twoColumnWatchNextResults"]["secondaryResults"]\ ["secondaryResults"]["results"] - # result = yt_initial_data - # return result - def get_useful_recommendation_data(r): if "compactVideoRenderer" in r: return r["compactVideoRenderer"]