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

43
main.py Normal file → Executable file
View File

@ -4,6 +4,7 @@ import holidays
from selenium import webdriver from selenium import webdriver
import time import time
from selenium.webdriver import ActionChains from selenium.webdriver import ActionChains
import os
day = datetime.datetime.now().weekday() day = datetime.datetime.now().weekday()
#refomroep_url = "https://reformatorischeomroep.nl" #refomroep_url = "https://reformatorischeomroep.nl"
@ -13,19 +14,31 @@ spijkenissee_omroep_url = "https://www.dearkspijkenisse.nl/kerkdiensten"
feestdagen = holidays.NL() feestdagen = holidays.NL()
sunday = False sunday = False
#unmute
os.system("amixer set Master unmute")
os.system("amixer set Master 80%")
#Get day of week and feestday. #Get day of week and feestday.
if(day == 6): if(day == 6):
print("Its a sunday!") print("Its a sunday!")
sunday = True sunday = True
else: else:
if(day in feestdagen): if(datetime.date.today() in feestdagen):
print("Its a dutch holliday!") 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 sunday = True
else:
print("Not a church time, assuming it is not a church day!")
else: else:
print("Its a weekday") print("Its a weekday")
if(sunday):
driver = webdriver.Firefox(executable_path="./geckodriver") driver = webdriver.Firefox(executable_path="./geckodriver")
def PlayMe():
if(sunday):
driver.get(spijkenissee_omroep_url) driver.get(spijkenissee_omroep_url)
time.sleep(7) time.sleep(7)
button = driver.find_element_by_xpath('//html//body//div[1]//div//div[1]//div[3]//div[2]//iframe[1]') button = driver.find_element_by_xpath('//html//body//div[1]//div//div[1]//div[3]//div[2]//iframe[1]')
@ -33,10 +46,30 @@ if(sunday):
actionChains = ActionChains(driver) actionChains = ActionChains(driver)
actionChains.move_to_element(button).click().perform() actionChains.move_to_element(button).click().perform()
else: else:
driver = webdriver.Firefox(executable_path="./geckodriver")
driver.get(refomroep_url) driver.get(refomroep_url)
time.sleep(7) time.sleep(2)
button = driver.find_element_by_xpath('//html//body//div//main//section//div[1]//div//iframe') 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) print(button.location)
actionChains = ActionChains(driver) actionChains = ActionChains(driver)
actionChains.move_to_element(button).click().perform() 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