Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions EsportsCapsuleFarmer/Match.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from selenium.webdriver.common.by import By
import time
from datetime import datetime, timedelta
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import TimeoutException, WebDriverException

from EsportsCapsuleFarmer.Rewards import Rewards
from EsportsCapsuleFarmer.Providers.Twitch import Twitch
Expand Down Expand Up @@ -44,7 +44,13 @@ def watchForMatches(self, delay):
while True:
self.driver.switch_to.window(self.originalWindow) # just to be sure
time.sleep(2)
self.driver.get("https://lolesports.com/schedule")
try:
self.driver.get("https://lolesports.com/schedule")
except WebDriverException as e:
self.log.error("Checking for live matches failed, webdriver exception: %s", e.msg)
self.log.info(f"Next check: {datetime.now() + timedelta(seconds=delay)}")
time.sleep(delay)
continue
time.sleep(5)
liveMatches = self.getLiveMatches()
if len(liveMatches) == 1:
Expand Down Expand Up @@ -90,13 +96,18 @@ def openNewMatches(self, liveMatches):
for match in newLiveMatches:
self.driver.switch_to.new_window('tab')
time.sleep(2)
self.currentWindows[match] = self.driver.current_window_handle
if match in self.OVERRIDES:
url = self.OVERRIDES[match]
self.log.info(f"Overriding {match} to {url}")
else:
url = match
self.driver.get(url)
try:
self.driver.get(url)
except WebDriverException as e:
self.log.error("Opening match %s failed, webdriver exception: %s", url, e.msg)
self.driver.close()
continue
self.currentWindows[match] = self.driver.current_window_handle
self.rewards.checkRewards(url)
try:
self.twitch.setTwitchQuality()
Expand Down
17 changes: 13 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import TimeoutException, WebDriverException
import time
import argparse

Expand Down Expand Up @@ -49,12 +49,15 @@
input()
exit()

loginHandler = LoginHandler(log=log, driver=driver)

driver.get("https://lolesports.com/schedule")
try:
url = "https://lolesports.com/schedule"
driver.get(url)
except WebDriverException as e:
log.error("Failed to open %s, webdriver exception: %s", url, e.msg)

# Handle login
if hasAutoLogin:
loginHandler = LoginHandler(log=log, driver=driver)
try:
loginHandler.automaticLogIn(username, password)
except TimeoutException:
Expand All @@ -63,6 +66,12 @@
driver.quit()
log.info("Exiting...")
exit()
except WebDriverException as e:
log.error("Automatic login failed, webdriver exception: %s", e.msg)
if isHeadless:
driver.quit()
log.info("Exiting...")
exit()

while not driver.find_elements(by=By.CSS_SELECTOR, value="div.riotbar-summoner-name"):
if not hasAutoLogin:
Expand Down