add more error checking
This commit is contained in:
parent
03f2df68a5
commit
0042deb1f3
1 changed files with 9 additions and 3 deletions
12
bot.py
12
bot.py
|
@ -35,8 +35,11 @@ async def on_ready():
|
|||
def play_video(videourl):
|
||||
driver.get(videourl)
|
||||
sleep(4)
|
||||
elem = driver.find_element(By.CLASS_NAME, "ytp-fullscreen-button")
|
||||
elem.send_keys(Keys.RETURN)
|
||||
try:
|
||||
elem = driver.find_element(By.CLASS_NAME, "ytp-fullscreen-button")
|
||||
elem.send_keys(Keys.RETURN)
|
||||
except Exception:
|
||||
return #if this errors there is no fullscreen options, such as playlists, so skip the link
|
||||
#guess I don't need this
|
||||
#sleep(1.5)
|
||||
#elem = driver.find_element(By.XPATH, '//button[@aria-keyshortcuts="k"]')
|
||||
|
@ -52,7 +55,10 @@ def play_video(videourl):
|
|||
elem.send_keys(Keys.RETURN)
|
||||
except Exception:
|
||||
pass
|
||||
endscreen = driver.find_element(By.CLASS_NAME, "html5-endscreen")
|
||||
try:
|
||||
endscreen = driver.find_element(By.CLASS_NAME, "html5-endscreen")
|
||||
except Exception:
|
||||
return #same as above
|
||||
while str(endscreen.get_attribute('style')) == "display: none;":
|
||||
pass
|
||||
sleep(2)
|
||||
|
|
Loading…
Reference in a new issue