mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2026-03-07 13:01:37 +00:00
Fix search
This commit is contained in:
parent
ad1f8df7cb
commit
861f441f9f
2 changed files with 5 additions and 2 deletions
|
|
@ -21,7 +21,10 @@ def extract_search(q):
|
|||
r.raise_for_status()
|
||||
content = r.content.decode("utf8")
|
||||
yt_initial_data = extract_yt_initial_data(content)
|
||||
items = yt_initial_data["contents"]["twoColumnSearchResultsRenderer"]["primaryContents"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"]
|
||||
sections = yt_initial_data["contents"]["twoColumnSearchResultsRenderer"]["primaryContents"]["sectionListRenderer"]["contents"]
|
||||
# find the section with the videos, not the one with the ads
|
||||
section = next(s for s in sections if "itemSectionRenderer" in s and not (len(s["itemSectionRenderer"]["contents"]) >= 1 and "carouselAdRenderer" in s["itemSectionRenderer"]["contents"][0]))
|
||||
items = section["itemSectionRenderer"]["contents"]
|
||||
results = []
|
||||
for item in items:
|
||||
if "videoRenderer" in item:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue