A web application that scrapes your McMaster University course schedule from Mosaic and imports it directly into Google Calendar.
mosaicsync.mp4
- Automated Scraping: Log in to Mosaic and extract your course schedule automatically.
- Google Calendar Integration: Import your classes as events in Google Calendar with proper details.
- Select Target Google Calendar: Choose which of your Google Calendars to import the schedule into.
- Date Range Selection: Specify which weeks of the term you want to import.
- Real-time Progress Updates: Watch the progress as your schedule is scraped and imported.
- Error Handling: Robust error handling with descriptive messages.
- Distributable Executable: Bundled application for Windows and macOS using PyInstaller, allowing easy execution without a Python environment.
- Automatic Browser Launch: The application automatically opens in your default web browser when the executable is run.
- Python 3.10+
- Google Cloud Platform account with Google Calendar API enabled
- Google OAuth 2.0 credentials (for Google Calendar access)
-
Clone this repository:
git clone <your-repo-url> cd schedule-scraper -
Create and activate a virtual environment:
python -m venv .venv # On Windows .venv\Scripts\activate # On macOS/Linux source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Setup Google Cloud OAuth credentials:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Calendar API
- Create OAuth 2.0 credentials (Desktop application type)
- Download the credentials JSON file
- Rename it to
credentials.jsonand place it in the project root directory
-
Create a
.envfile in the project root with the following content:MACID_USER=your_macid_username MACID_PASS=your_macid_passwordNote: These will be the default values in the web form but can be overridden.
-
Start the application:
python run.py -
Open your web browser and navigate to:
http://127.0.0.1:5000/ -
Follow the steps in the web interface:
- Authorize Google Calendar access (you'll only need to do this once, or if scopes change).
- Select your target Google Calendar from the dropdown.
- Enter your MacID and password.
- Select the date range for your schedule.
- Click "Import Schedule"
- Monitor the progress until completion.
- Download the
MosaicSync.exe(for Windows) or the corresponding macOS application from the releases page (once available). - Ensure
credentials.jsonis in the same directory as the executable, or in adatasubdirectory if configured that way in the.specfile. The first time you run it,token.jsonwill be created in the same directory after you authorize with Google. - Double-click the executable. It will start the local server and automatically open the web interface in your default browser (
http://127.0.0.1:5000/). - Follow the steps in the web interface as outlined above (select calendar, enter credentials, import).
- To stop the application, close the terminal window that opened when you launched the executable.
.
├── app/ # Flask application
│ ├── __init__.py # Flask app initialization
│ ├── routes.py # Web routes
│ ├── static/ # Static assets
│ │ ├── css/ # Stylesheets
│ │ └── js/ # JavaScript files
│ ├── templates/ # HTML templates
│ │ ├── base.html # Base template
│ │ └── index.html # Main page
│ └── task_manager.py # Handles background import tasks
├── build/ # PyInstaller build directory (temporary)
├── dist/ # PyInstaller output directory (contains executable)
├── .env # Environment variables (for development)
├── .gitignore # Specifies intentionally untracked files
├── config.py # Configuration settings
├── credentials.json # Google OAuth credentials (REQUIRED)
├── gcal_service.py # Google Calendar API service
├── mosaicsync.ico # Application icon
├── mosaicsync.spec # PyInstaller specification file
├── README.md # This file
├── requirements.txt # Python dependencies
├── run.py # Application entry point
├── scraper.py # Mosaic scraping functionality
└── token.json # Google API authentication token (generated after auth)
This project uses PyInstaller to bundle the Flask application into a standalone executable.
- Python 3.10+
- All dependencies from
requirements.txtinstalled. - PyInstaller:
pip install pyinstaller
-
Prepare
credentials.json: Ensure yourcredentials.jsonfile from Google Cloud Console is in the project root. -
Modify
mosaicsync.spec(if needed):- This file tells PyInstaller how to build the executable.
- It includes paths to static files, templates, and
credentials.json. - The
datassection is crucial for including non-Python files. - For a production build without a console window (on Windows), you can change
console=Truetoconsole=Falsein the.specfile.
-
Build the Executable: Open your terminal in the project root directory and run:
pyinstaller mosaicsync.spec
Or, for a one-file executable (may have slower startup):
pyinstaller --onefile run.py --name MosaicSync --add-data "app/static:app/static" --add-data "app/templates:app/templates" --add-data "credentials.json:." --add-data "mosaicsync.ico:." --windowed --icon=mosaicsync.ico
(Note: The
.specfile provides more control and is the recommended method for this project due to theresource_pathfunction usage). -
Find the Executable: The bundled application will be in the
dist/MosaicSyncfolder (ordist/MosaicSync.exeif using--onefile). -
Distribution:
- For Windows, distribute the
MosaicSyncfolder (orMosaicSync.exe). Users will need to place theircredentials.jsonalongside the executable (or as configured in the spec).token.jsonwill be generated upon first Google authentication. - For macOS, the process is similar. You'll run PyInstaller on a macOS machine. The output will be a
.appbundle.
- For Windows, distribute the
- Add duplicate event detection to avoid creating the same event twice
- Add event categorization by course type (lectures, labs, tutorials)
- Improve error handling and retry mechanisms
- Add support for different term schedules
- Package for macOS and Linux
- This application requires your Mosaic credentials to log in and scrape your schedule.
- Credentials are only stored in your local
.envfile and not transmitted beyond the authentication with Mosaic. - Google Calendar access is obtained through OAuth 2.0, which does not expose your Google password.
- The application requests only the minimum required permissions to create calendar events.