Please note that this project is a work in progress, and both the readme and the code are not yet finalized.
This project provides a Python-based solution to scrape university timetables and integrate them into Google Calendar. It allows users to automate the process of fetching timetable data, preparing event data, and updating Google Calendar with the timetable events.
- Timetable Scraper: Scrapes timetable data and saves it as a JSON file.
- Google Calendar Integration: Authenticates with Google Calendar API and updates the calendar with the timetable events.
- Dry Run Mode: Allows testing without making actual changes to the Google Calendar.
- Logging: Provides detailed logging for monitoring and debugging.
-
Clone the Repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
-
Create and Activate a Virtual Environment:
python3 -m venv venv source venv/bin/activate
-
Install the Required Dependencies:
pip install -r requirements.txt
-
Google API Credentials:
- Obtain your Google API credentials from the Google Cloud Console.
- Download the
client_secret.json
file and save it in theconfig
directory.
-
Setup Token Storage:
- Ensure you have a
config
directory in the project root. - The script will store the OAuth token in
config/token.json
after the first successful authentication.
- Ensure you have a
-
Update Constants:
- Open
update_timetable_google_api.py
and update the following constants:SCOPES = ["https://www.googleapis.com/auth/calendar"] TOKEN_JSON_FILE = "config/token.json" CREDENTIALS_JSON_FILE = "config/client_secret.json" CALENDAR_ID_ELM2 = "your-calendar-id-elm2" CALENDAR_ID_ELM4 = "your-calendar-id-elm4" TIME_ZONE = "Europe/Berlin" MAX_RESULTS = 2500
- Open
-
Prepare Timetable Data:
- Ensure your timetable data is available in
output/final_events.json
.
- Ensure your timetable data is available in
-
Run the Script:
- To update Google Calendar with the timetable events:
python -u src/timetable_scraper/libs/update_timetable_google_api.py
- To update Google Calendar with the timetable events:
-
Dry Run Mode:
- Use dry run mode to test the script without making actual changes to the Google Calendar.
- In
update_timetable_google_api.py
, setdry_run = True
:if __name__ == "__main__": dry_run = True # Set to False to perform actual operations main(dry_run)
-
Output:
- The script will log the actions it would have taken and save the prepared event data to
output/dry_run_output.csv
.
- The script will log the actions it would have taken and save the prepared event data to
- The project uses a logging configuration to provide detailed logs.
- Logs will be printed to the console and saved to a file (if configured in
log_config.py
).
- Fork the repository.
- Create your feature branch (
git checkout -b feature/fooBar
). - Commit your changes (
git commit -am 'Add some fooBar'
). - Push to the branch (
git push origin feature/fooBar
). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.