Skip to content

This project synchronizes events from the IEEE vTools API to a Google Calendar. It fetches events for a specific country (Colombia by default) and adds or updates them in a Google Calendar.

License

Notifications You must be signed in to change notification settings

Crola1702/vtools_calendar_synchronizer

Repository files navigation

Event Calendar Synchronizer

See public events from IEEE Colombia in: IEEE Colombia Events

This project synchronizes events from the IEEE vTools API to a Google Calendar. It fetches events for a specific country (Colombia by default) and adds or updates them in a Google Calendar.

Features

  • Fetches events from the IEEE vTools API.
  • Filters events by country.
  • Synchronizes events with a Google Calendar:
    • Adds new events.
    • Updates existing events if they have changed.
    • Skips events that are already up-to-date.

Requirements

  • Python 3.7 or higher
  • Google Calendar API credentials
  • Internet connection

Setup

Docker quickstart

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-folder>
  2. Build the Docker image:

    docker build -t event-calendar-synchronizer .
  3. Run the Docker container:

    docker run -it --rm event-calendar-synchronizer --calendar-id <calendar_id> --country-id <country_id>

You can also use an .env file to set up the environment variables for the Docker container.

  1. Set up Configuration:

    • Copy .env.example to .env
    • Update .env file with your data
  2. Run the Docker container:

    docker build -t event-calendar-synchronizer .
    docker run -it --env-file=.env --rm event-calendar-synchronizer

Local Setup

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-folder>
  2. Install dependencies: Install the required Python packages using pip:

    pip -m venv .venv
    source ./.venv/bin/activate
    pip install -r requirements.txt
  3. Set up Configuration:

    • Copy .env.example to .env
    • Update .env file with your data
  4. Set up Google Calendar API credentials:

    • See Python quickstart to set up the Google Calendar API credentials.
    • Move the client secret JSON file to the project folder and rename it to credentials.json.
  5. Run the script: You can run the script using Python and adding extra arguments (you can use --help to see all the options):

    python main.py --calendar-id <calendar_id> --country-id <country_id>

The first time you run the script, it will prompt you to authenticate with your Google account. This will generate a token.json file for future use. bash python main.py

See

How It Works

  1. Fetching Events:
  • The script uses the IEEE vTools API to fetch a list of events.
  • Events are filtered by the country ID (Colombia's ID is 45).
  1. Event Synchronization:
  • The script initializes the CalendarAPI class, which handles communication with the Google Calendar API.
  • For each event fetched from the vTools API:
    • If the event does not exist in the calendar, it is added.
    • If the event exists but has been updated, it is modified in the calendar.
    • If the event is already up-to-date, no changes are made.
  1. Statistics:
  • At the end of the synchronization process, the script prints a summary of the number of events added, updated, and unchanged.

Configuration

Country ID: The country ID can be changed in the main.py file. The default country is Colombia (ID: 45).

To look for country you can use the following command:

$ curl "https://events.vtools.ieee.org/RST/events/api/public/v5/countries/list" | jq '.data[] | select(.attributes.name == "Colombia") | .attributes | del(.states) | .'

{
  "id": 45,
  "name": "Colombia",
  "abbreviation": "CO"
}

Google Calendar ID: The Google Calendar ID can be changed in the calendar_api.py file. The default calendar is the primary calendar of the authenticated user.

Replace this with the ID of the calendar you want to use. You can find the ID in the Google Calendar settings.

File Structure

credentials.json       # Google API credentials
token.json             # Generated after authentication
lib/
    __init__.py        # Empty file for module initialization
    calendar_api.py    # Handles Google Calendar API interactions
    vtools_fetcher.py  # Fetches and processes events from the IEEE vTools API
main.py                # Entry point for the script
README.md              # Project documentation

About

This project synchronizes events from the IEEE vTools API to a Google Calendar. It fetches events for a specific country (Colombia by default) and adds or updates them in a Google Calendar.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published