From 8d60dc74e48bdc3062453e9fdd5f064c485f7c67 Mon Sep 17 00:00:00 2001 From: gottagofaster236 Date: Fri, 24 Jul 2020 13:22:33 +0300 Subject: [PATCH] Finally fixed the bug where waiting for the stream to begin didn't work. --- main.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 0cd98ba..b32ca0e 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ import atexit import os import pickle import re -from time import sleep +import time from selenium.common.exceptions import * from selenium.webdriver.chrome.options import Options from hidden_chrome_driver import HiddenChromeWebDriver @@ -83,10 +83,8 @@ def load_url(url): global is_fullscreen if driver.current_url != url: driver.get(url) - else: - driver.refresh() - is_fullscreen = False - sleep(PAGE_LOAD_WAIT_SECONDS) + is_fullscreen = False + sleep(PAGE_LOAD_WAIT_SECONDS) def get_streamer_url(): @@ -163,7 +161,9 @@ def set_online(new_online): else: print("The streamer is offline currently.") print("Wait for him to go live, or close the program by pressing Ctrl+C.") - load_url("about:blank") + + if not is_online: + load_url("about:blank") def check_for_raid_redirect(): @@ -226,6 +226,13 @@ def exit_handler(): os.system("taskkill /im chrome.exe /f") +def sleep(t): # workaround so that sleep doesn't block keyboard interrupt + while t >= 1: + time.sleep(1) + t -= 1 + time.sleep(t) + + if __name__ == "__main__": try: main()