diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-09-08 10:32:52 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-09-08 10:32:52 -0700 |
commit | 3c9a6dd8e6c114cda16426fffb34cce60f2535c8 (patch) | |
tree | d6fc5f9b5e79a6888599842beb51989fdb7dc649 /youtube | |
parent | cd04bbc5ceda2514ee053966e8ec91bcfc22a0f1 (diff) | |
download | yt-local-3c9a6dd8e6c114cda16426fffb34cce60f2535c8.tar.lz yt-local-3c9a6dd8e6c114cda16426fffb34cce60f2535c8.tar.xz yt-local-3c9a6dd8e6c114cda16426fffb34cce60f2535c8.zip |
Search: Fix advertisements for google products like home/stadia breaking search results
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/search.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube/search.py b/youtube/search.py index e35d0cb..e167279 100644 --- a/youtube/search.py +++ b/youtube/search.py @@ -78,7 +78,11 @@ def get_search_page(): estimated_results = int(info[1]['response']['estimatedResults']) estimated_pages = ceil(estimated_results/20) - results = info[1]['response']['contents']['twoColumnSearchResultsRenderer']['primaryContents']['sectionListRenderer']['contents'][0]['itemSectionRenderer']['contents'] + + # almost always is the first "section", but if there's an advertisement for a google product like Stadia or Home in the search results, then that becomes the first "section" and the search results are in the second. So just join all of them for resiliency + results = [] + for section in info[1]['response']['contents']['twoColumnSearchResultsRenderer']['primaryContents']['sectionListRenderer']['contents']: + results += section['itemSectionRenderer']['contents'] parsed_results = [] corrections = {'type': None} |