I'm writing a script to download some youtube videos into mp3 and want the code to start a single download and after that continue with the other and the other and so on. The thing is, after the first download finishes, something brokes and starts to skipping download and not waiting for the download to finish to continue. Here's what I wrote, hope you can help me:
for names in items:
stringName = "".join(names)
driver.get("https://www.youtube.com/results?search_query=" + stringName)
time.sleep(6)
driver.find_element_by_xpath("//a[@id='video-title']").click()
songLink = driver.current_url
driver.get("https://ytbmp3.club/")
driver.find_element_by_id("dlURL").send_keys(songLink, Keys.RETURN)
driver.find_element_by_xpath("//iframe[@class='embed-responsive-item']").click()
time.sleep(10)
wait = True
while (wait == True):
for fname in os.listdir('C:\\Users\\sdf\\Desktop\\pruebatelgspo'):
if ('.crdownload') in fname:
print('downloading files ...')
time.sleep(10)
else:
wait = False
print('finished downloading all files ...')