Button press no longer working
This commit is contained in:
parent
3c187dd65b
commit
9e246e6297
3
Runme.sh
Executable file
3
Runme.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
cd Opa_omroep-automatiseren/
|
||||
python3 main.py
|
BIN
geckodriver
BIN
geckodriver
Binary file not shown.
1580
geckodriver.log
Normal file → Executable file
1580
geckodriver.log
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
71
main.py
Normal file → Executable file
71
main.py
Normal file → Executable 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
0
requirements.txt
Normal file → Executable file
Loading…
Reference in New Issue
Block a user