Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #6 from LeagueOfPoro/dev
Browse files Browse the repository at this point in the history
Support for Twitch quality settings
  • Loading branch information
LeagueOfPoro committed Jul 7, 2022
2 parents abca555 + 7b90f3f commit 2ef681c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
21 changes: 18 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2ef681c

Please sign in to comment.