Not really sure where to put this, but I thought I'd share it anyway.
I work at a grocery store in Australia that uses a service called WorkJam to send us our shifts for the week. However, I find the app really frustrating because it's slow and it's just annoying and repetitive to put my shifts into Google Calendar. So, I decided to make something that does this for me after taking some inspiration from Tim Ferriss' four-hour work week book.
Here's a general outline of how it works under the hood:
- Simulate a browser.
- Go to workjam website.
- Go through login process.
- Go to schedule url.
- Scrape the shifts from a table.
- Parse the data.
- Use gcalcli terminal command to handle putting data into Google Calendar.
The technical stuff:
- I'm running this all in a Linux Docker container and developing locally using WSL2 Ubuntu 20.04 in Visual Studio. This image will be run once a week on a Monday at some point on the AWS Elastic Container Service.
- I'm using .NET 6 for this as I've had experience with this before and I like C#, but I could've written it with any other language if I really wanted to.
- I initially decided to use Selenium for the browser emulation. However, I ran into issues getting the chromedriver installed and Selenium isn't updated for .NET 6 yet, so I decided to look for an alternative.
- I settled on a Microsoft maintained solution called PlayWright. This works great as it has lots of great tools packaged with it and it handles the browser downloads for Chrome, Firefox, and Webkit.
- I basically just followed the login process from here. Once I'd reached the page for the schedule, I just did a bit of snooping and analysed the table structure to get the desired data I looked for. This was just a bit of experimentation.
- After this, I tried using the Google Calendar API for .NET, but the docs are s**t and I was basically banging my head against a wall. A developer recommended using gcalcli and just executing it from .NET, which I figured out how to do using the CliWrap package for .NET and piped in the input I would've done on the command line with a million new lines.
I don't really know how to demonstrate it doing it as it's mostly background stuff apart from maybe a screenshare showing the before and after it's run.
Side note: Anyone who has livestreamed coding an application, how do you keep your personal details safe which in the coding environment? I was considering doing this, but I thought it would be too easy to slip up on a project like this where it's my personal login's and google calendar api keys and such.
Ha, I love this kind of automation — scratching your own itch is the best way to start building. The Google Calendar API docs being frustrating is painfully relatable. I've been building a calendar sync tool (Google ↔ Outlook) and Google's rate limit handling alone was a journey — they return 403 instead of 429 for rate limits, and their own retry library doesn't catch it. Playwright is a great choice btw, way smoother than Selenium in my experience too.