aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-09-08 10:32:52 -0700
committerJames Taylor <user234683@users.noreply.github.com>2019-09-08 10:32:52 -0700
commit3c9a6dd8e6c114cda16426fffb34cce60f2535c8 (patch)
treed6fc5f9b5e79a6888599842beb51989fdb7dc649 /youtube
parentcd04bbc5ceda2514ee053966e8ec91bcfc22a0f1 (diff)
downloadyt-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.py6
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}