The aim of this repository is to make a script which converts an image (screenshot) of the timetable of my university (VIT) to a calendar which can be synced with my personal/work google calendar with a simple click.
This script was developed with Python 3.9.7, if you haven't installed python check out this guide
- Pip, a package manager for python is essential to download/upgrade the required libraries to run this script.
To check whether it is installed run
pip --version
in your command line (cmd), if pip is not installed make sure to install with the help of this guide - We will now need to install the required modules, to do so enter
pip install -r requirements.txt
in the cmd, which would open the requirements.txt file and install accordingly the modules neccessary.
There are two APIs in use for this script to run successfully
- Nanonets, which is given the image of the timetable and returns a json file.
- Google Calendar API, which adds the events to the user's google calendar.
Create an account if you don't have one in Nanonets. We essentially need two things - your API key and Model ID, which need to be stored in a text file in seperate lines respectively in the same directory as your script.
i) After Logging in, create a new model by clicking on the New Model button ii) Select Tables as we are converting a jpeg/png file to a tabular format (csv)
- Getting the API Key
iii) Create a txt file named nanonetsInfo.txt
and copy the API Key into first line of the text file.
- Getting the Model ID
i) Click Model Settings which would give you your model ID
ii) Make sure to copy your modelID and save it in the text file named nanonetsInfo.txt
in the second line
- Create a google cloud account (different from a regular google account) if you don't have an existing one.
- Go to this link where you will need to create a project and enable calendar API.
- Go to Credentials and create an OAuth2.0 client, in this script's case you would need to select it Desktop app and feel free to name it whatever you feel is apt.
- After doing so, download the credentials as a json file (which is the default) and rename it to
client_secret.json
in the same directory/folder as the the python files. For more information regarding this setup you may follow this tutorial
- Make sure to have the screenshot of the timetable in the highest quality possible in the same directory as your python files.
- Change the value of
pathOfImage
to the absolute or relative path of the image, by default the name of the file is to be 'timetable.png' - You may change the variable
calendarName
to change the name of the calendar which appears in your calendar
If you face any issues or have any questions feel free to contact me on LinkedIn : www.linkedin.com/in/joel-james-318593220