diff --git a/bot.py b/bot.py index 1b4aff1..ac5e270 100644 --- a/bot.py +++ b/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)