1
0
Fork 0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2026-03-07 13:01:37 +00:00

Extract fact check notices to second__clarification

This commit is contained in:
Cadence Ember 2021-11-04 02:01:52 +13:00
parent 65bb7a2c4c
commit e3854a6050
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
2 changed files with 17 additions and 1 deletions

View file

@ -7,7 +7,7 @@ import traceback
import yt_dlp
import urllib.error
from tools.converters import *
from tools.extractors import extract_yt_initial_data, extract_yt_initial_player_response
from tools.extractors import extract_yt_initial_data, extract_yt_initial_player_response, deep_get
import tools.files as files
from math import floor
from urllib.parse import parse_qs, urlparse, urlencode
@ -317,6 +317,12 @@ def get_more_stuff_from_file(id, result):
"second__remoteUrl": url
})
# fact check notices! aka "clarifications".
# for now, we just return the data as-is for the renderer to deal with (or not).
def get_clarification(section):
return deep_get(section, ["itemSectionRenderer", "contents", 0, "clarificationRenderer"])
result["second__clarification"] = next((get_clarification(s) for s in main_sections if get_clarification(s)), None)
except Exception:
print("messed up extracting recommendations.")
traceback.print_exc()