Skip to content

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.

Notifications You must be signed in to change notification settings

lennart-rth/HSP_Automation

Repository files navigation

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.

A docker image for Chromedriver is also available.

  1. It runs 10 min. after the course has started and books for next week.
  2. Requires Firefox´s geckodriver or Chromes Chromedriver in bash etc
  3. Logs and Errors can be found in executions.txt. Raw Crontab output is found in crontab_log.txt. A History of all booked courses is in booked.txt.

Installation

  1. python3 -m venv venv
  2. source venv/bin/activate
  3. pip3 install -r requirements.txt
  4. 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 or sudo apt-get install chromium-browser).

Installing for the docker image:

  1. docker build -t hspautomation .

User specific setup

  1. 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
  2. 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.

  1. Folow this to setup Google Cloud Project and this to setup a service-acount.
  2. Generate a Key and download ist credentials into a credentials.json file into the project directory.
  3. Generate a new Calender and share it with your service-account. (All previleges)
  4. 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

To run in Docker

docker run --rm -w /home/pi/HSP_Automation -v $(pwd):/home/pi/HSP_Automation hspautomation python HSP-automation.py $1 $2 >> ~/HSP_Automation/crontab_log.txt

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published