From 1dec5ffc498e508cf5738d2883e7e58faf7e9f8f Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Thu, 12 Jan 2017 08:29:29 +0530 Subject: [PATCH] maybe fix #25 ? --- spotdl.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spotdl.py b/spotdl.py index 4e18552..07d4c44 100644 --- a/spotdl.py +++ b/spotdl.py @@ -20,14 +20,13 @@ spotify = spotipy.Spotify() def searchYT(number): items = (requests.request(method='GET', url=URL)).text - zoom1 = items.find('yt-uix-tile-link') - zoom2 = items.find('yt-uix-tile-link', zoom1+1) - zoom3 = items.find('yt-uix-tile-link', zoom2+1) - part = items[zoom1-100: zoom2] items_parse = BeautifulSoup(items, "html.parser") first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[0]['href'] - if not first_result.find('channel') == -1: - first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[1]['href'] + check = 1 + while not first_result.find('channel') == -1: + first_result = items_parse.find_all(attrs={'class':'yt-uix-tile-link'})[check]['href'] + check += 1 + del check full_link = "youtube.com" + first_result #print(full_link) global video