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
|
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,30 +14,62 @@ 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()))
|
||||||
sunday = True
|
#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:
|
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():
|
||||||
driver.get(spijkenissee_omroep_url)
|
if(sunday):
|
||||||
time.sleep(7)
|
driver.get(spijkenissee_omroep_url)
|
||||||
button = driver.find_element_by_xpath('//html//body//div[1]//div//div[1]//div[3]//div[2]//iframe[1]')
|
time.sleep(7)
|
||||||
print(button.location)
|
button = driver.find_element_by_xpath('//html//body//div[1]//div//div[1]//div[3]//div[2]//iframe[1]')
|
||||||
actionChains = ActionChains(driver)
|
print(button.location)
|
||||||
actionChains.move_to_element(button).click().perform()
|
actionChains = ActionChains(driver)
|
||||||
else:
|
actionChains.move_to_element(button).click().perform()
|
||||||
driver = webdriver.Firefox(executable_path="./geckodriver")
|
else:
|
||||||
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')
|
||||||
print(button.location)
|
#/html/body/div/main/section/div[1]/d
|
||||||
actionChains = ActionChains(driver)
|
button.location[0] = 10
|
||||||
actionChains.move_to_element(button).click().perform()
|
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