From 2b103d9b018929b3bf0f83ed4a6f2c95e028a406 Mon Sep 17 00:00:00 2001 From: kuba Date: Thu, 7 Jul 2022 12:22:30 +0200 Subject: [PATCH 1/2] Automatically set Twitch quality to lowest possible --- main.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index c47f631..e9622ba 100644 --- a/main.py +++ b/main.py @@ -17,6 +17,7 @@ "https://lolesports.com/live/lck":"https://lolesports.com/live/lck/lck", "https://lolesports.com/live/lec":"https://lolesports.com/live/lec/lec", "https://lolesports.com/live/lcs":"https://lolesports.com/live/lcs/lcs", + "https://lolesports.com/live/lco":"https://lolesports.com/live/lco/lco", "https://lolesports.com/live/cblol_academy":"https://lolesports.com/live/cblol_academy/cblol" } CONFIG_LOCATION="config.yaml" @@ -56,6 +57,15 @@ def logIn(driver, username, password): wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "div.riotbar-summoner-name"))) +def setTwitchQuality(driver): + wait = WebDriverWait(driver, 10) + wait.until(ec.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe[title=Twitch]"))) + settingsButton = wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "button[data-a-target=player-settings-button]"))) + driver.execute_script("arguments[0].click();", settingsButton) + qualityButton = wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "button[data-a-target=player-settings-menu-item-quality]"))) + driver.execute_script("arguments[0].click();", qualityButton) + options = wait.until(ec.presence_of_all_elements_located((By.CSS_SELECTOR, "input[data-a-target=tw-radio]"))) + driver.execute_script("arguments[0].click();", options[-1]) ################################################### log = logging.getLogger("League of Poro") @@ -66,7 +76,7 @@ def logIn(driver, username, password): hasAutoLogin = False isHeadless = False username = "NoUsernameInConfig" # None -password = "NoPasswordInConfig" # None +password = "NoPasswordInConfig" # None try: config = readConfig(CONFIG_LOCATION) hasValidConfig = True @@ -90,7 +100,6 @@ def logIn(driver, username, password): options.add_argument("--headless") driver = webdriver.Chrome(options=options) driver.get("https://lolesports.com/") -time.sleep(2) if hasAutoLogin: try: @@ -115,7 +124,7 @@ def logIn(driver, username, password): while True: driver.switch_to.window(originalWindow) # just to be sure - time.sleep(5) + time.sleep(2) driver.get("https://lolesports.com/") time.sleep(5) liveMatches = getLiveMatches(driver) @@ -147,6 +156,12 @@ def logIn(driver, username, password): else: url = match driver.get(url) + time.sleep(5) + try: + setTwitchQuality(driver) + log.info("Twitch quality set successfully") + except: + log.warning(f"Cannot set the Twitch player quality. Is the match on Twitch?") time.sleep(30) driver.switch_to.window(originalWindow) From 7b90f3fe727d46097fba5e13d36f8c64fb15b597 Mon Sep 17 00:00:00 2001 From: League of Poro <95635582+LeagueOfPoro@users.noreply.github.com> Date: Thu, 7 Jul 2022 12:30:07 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bc8cf79..0f04f8e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This tool makes the Chrome browser watch the matches for you! - Closes finished matches - Automatically logs user in - Runs in background +- Sets Twitch quality to lowest possible ## Requirements - [Chrome browser](https://www.google.com/chrome/)