NewLeaf: Fix recommended videos extraction for COVID-related videos v2 SUPERSEDED

~lomanic: 1
 Fix recommended videos extraction for COVID-related videos

 1 files changed, 6 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~cadence/tube-devel/patches/26124/mbox | git am -3
Learn more about email & git

[PATCH NewLeaf v2] Fix recommended videos extraction for COVID-related videos Export this patch

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
+++ b/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:
Thanks for the heads up! I committed some code I wrote with the same
effect that I think is cleaner.