Button press no longer working

This commit is contained in:
Eljakim Herrewijnen 2021-01-16 16:52:58 +01:00
parent 3c187dd65b
commit 9e246e6297
6 changed files with 1058 additions and 596 deletions

0
README.md Normal file → Executable file
View File

3
Runme.sh Executable file
View File

@ -0,0 +1,3 @@
#! /bin/bash
cd Opa_omroep-automatiseren/
python3 main.py

Binary file not shown.

1580
geckodriver.log Normal file → Executable file

File diff suppressed because it is too large Load Diff

71
main.py Normal file → Executable file
View File

@ -4,6 +4,7 @@ import holidays
from selenium import webdriver
import time
from selenium.webdriver import ActionChains
import os
day = datetime.datetime.now().weekday()
#refomroep_url = "https://reformatorischeomroep.nl"
@ -13,30 +14,62 @@ spijkenissee_omroep_url = "https://www.dearkspijkenisse.nl/kerkdiensten"
feestdagen = holidays.NL()
sunday = False
#unmute
os.system("amixer set Master unmute")
os.system("amixer set Master 80%")
#Get day of week and feestday.
if(day == 6):
print("Its a sunday!")
sunday = True
else:
if(day in feestdagen):
print("Its a dutch holliday!")
sunday = True
if(datetime.date.today() in feestdagen):
print("Its a dutch holliday! {}".format(datetime.date.today()))
#Now check time
t = datetime.datetime.now()
if(t.hour > 9 and t.hour < 12):
print("Ochtendienst")
sunday = True
else:
print("Not a church time, assuming it is not a church day!")
else:
print("Its a weekday")
if(sunday):
driver = webdriver.Firefox(executable_path="./geckodriver")
driver.get(spijkenissee_omroep_url)
time.sleep(7)
button = driver.find_element_by_xpath('//html//body//div[1]//div//div[1]//div[3]//div[2]//iframe[1]')
print(button.location)
actionChains = ActionChains(driver)
actionChains.move_to_element(button).click().perform()
else:
driver = webdriver.Firefox(executable_path="./geckodriver")
driver.get(refomroep_url)
time.sleep(7)
button = driver.find_element_by_xpath('//html//body//div//main//section//div[1]//div//iframe')
print(button.location)
actionChains = ActionChains(driver)
actionChains.move_to_element(button).click().perform()
driver = webdriver.Firefox(executable_path="./geckodriver")
def PlayMe():
if(sunday):
driver.get(spijkenissee_omroep_url)
time.sleep(7)
button = driver.find_element_by_xpath('//html//body//div[1]//div//div[1]//div[3]//div[2]//iframe[1]')
print(button.location)
actionChains = ActionChains(driver)
actionChains.move_to_element(button).click().perform()
else:
driver.get(refomroep_url)
time.sleep(2)
button = driver.find_element_by_xpath('//html//body//div//main//section//div[1]//div//iframe')
#/html/body/div/main/section/div[1]/d
button.location[0] = 10
print(button.location)
actionChains = ActionChains(driver)
actionChains.move_to_element(button).click().perform()
return True
PlayMe()
exit()
count = 0
while(True):
count +=1
if(count > 10):
exit()
try:
if(PlayMe()):
break
except:
time.sleep(4)
print("Failed to press button or something else happened?")
driver.quit()
driver = webdriver.Firefox(executable_path="./geckodriver")

0
requirements.txt Normal file → Executable file
View File