We create the credentials creds with the code below. The credentials.json file is the file that you can download when enabling the APIs. We will use a service account to make use of the APIs in the project. NB_DAYS_BEFORE = 3 Using a service account This means that the new week menu will be generated a certain number of days before the previous week menu has finished. With NB_DAYS_BEFORE we give ourselves some slack. Sometimes we can’t go to the supermarket on the day a new week menu is created. You can specify your own traditions in a dictionary, with the name of the day as the key and the recipe as the value. And yes, before you’d ask, that is fries with mayonnaise. As we are from Belgium, this means eating fries once a week (for us on Thursday). With TRADITIONS, I mean that our family has a few days in the week on which we prepare a certain recipe. You can use your own event labels scheme. This event is one of the FREE_EVENTS.Īll the events are full-day events in the Google Calendars. When I have a day off, I add “HOLIDAY” to my calendar. For example: “B” stands for the afternoon shift. My wife works in shifts and adds them to her Google Calendar by using letter codes. I’ve also created a separate calendar to upload the recipes. But you could adapt the code to loop over more calendars. You can find the ID by executing this script from the APIs Explorer.įor this project, we will extract the events of only two calendars. Make sure you have access to all calendars you want to include. We need to specify the Google Calendar IDs to get the events from. So RANGE needs to be set to “recepten!A:G”. The screenshot below shows some sample content. In my Google sheet “recepten”, columns A to G contain information on each recipe. You can find the ID of your Google sheets by right-clicking on the sheet in Google Drive. Additionally, we specify the sheet range containing the recipes. We need to specify the ID of the Google sheet with the recipes. , ''] Google sheet ID and range SPREADSHEET_ID = We will need read and write access to both the calendars and sheet. With scopes, we define the access levels for the Google calendars and sheets. You can include them for your own app with values relevant to your case. I will discuss these parameters further below with fictitious values. import config as cfgįrom googleapiclient.discovery import buildįrom google.oauth2 import service_account Configurationįor privacy and security reasons, I keep some parameters in a separate config.py file. When that’s done, we continue by importing the necessary Python packages. This is very well explained on the web pages below: Before we can use the Google calendar and sheets in this project, we need to enable the API’s. Using the Google calendar API and Google sheets APIįirst, we’ll need to create a new Google Cloud project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |