HSP-booking-automation
An Cronjob automation that automaticly books your sport courses for the Hochschulsport Hamburg. This only works in combination with the HSP "Ab zum Sport Card". If a google Calender is integrated, it will automaticly generate events for every booked course.
- It runs 5 min. after the course has started and books for next week.
- Requires Firefox´s or Chromes geckodriver in bash etc
- Logs and Errors can be found in
executions.txt
. Raw Crontab output is found incrontab_log.txt
. A History of all booked courses is inbooked.txt
.
Installation
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
- get geckodriver for your OS from here: https://github.com/mozilla/geckodriver/releases. To run the script on Raspberry Pi you may have to use Chromes Selenium Driver (
sudo apt-get install chromium-chromedriver
orsudo apt-get install chromium-browser
).
User specific setup
- Make file called
settings.ini
and write:
[<Your_Name>]
Sport=[<url_to_sport_website_with_booking_button>,<XPATH_to_booking_button>,<Location_of_the_Event>]
!!! Change all Fields with <> accordingly - Make file called
.env
with your credentials:
EMAIL={:name@email.com}
PASSWORD={:<your_secret_passwd>}
!!! Change all Fields with <> accordingly
Note: These Passwords get saved as envoirenemt Variables and will not be seen by anyone. As long as you keep your.env
file secret.
Integrate Google Calendar
If you want to integrate Google Calender you have to setup a Google Service-account.
- Folow this to setup Google Cloud Project and this to setup a service-acount.
- Generate a Key and download ist credentials into a
credentials.json
file into the project directory. - Generate a new Calender and share it with your service-account. (All previleges)
- Add the following line ionto your
.env
file:
CALID={<Name>:<your_secret_calender_id>}
You can find your calendar Id in the setting for your calender.
Run the automation
Make a cronjob with the command:
35 19 * * 1 sh ~/HSP_Automation/run_booking.sh <Sport> <Your Name>
!!! Change "Your Name" and "Sport"-Value and Crontab-Timing accordingly