Skip to content

Automatically scrape SSSB Laundry portal, upload laundry dates to Google Calendar and book via an intuitive user interface

Notifications You must be signed in to change notification settings

didrikmunther/sssb-laundry-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSSB Laundry Automation

What is this?

In the Stockholm Student Housing (SSSB), the laundry rooms are booked through a website. The website is slow, and the booking process is cumbersome. This project aims to simplify the booking process by automatically scraping the website and sending calendar invites to the users, allowing them to book the laundry room directly from their calendar.

Demonstration

Problem - Existing Booking Page

Solution - This Project

Monthly View Daily View Laundry Time Website Booking

Setup

⚠️ This project is badly packaged: The deployment process is very ad-hoc for my purposes. It will probably not work out of the box for you.

1. Add Google API credentials

Create a new project in the Google Developer Console. Add the credentials as a credentials.json in the root directory.

2. Setup Root URL

Set the ROOT_URL variable in src/constants.ts, which is used to generate the calendar invite links back to your web server.

3. Add environment variables

Add the following values to a .env file in the root directory:

HTTP_USERNAME=MY_USERNAME
HTTP_PASSWORD=MY_PASSWORD
SQLITE_FILE=./db.sqlite

The HTTP username and password is used with HTTP Basic Auth to protect the laundry booking page.

4. Add Users

Step 1 - Create a Google Calendar user

Create a new Google account to use as an invite sender. This account will be used to send invites to the users.

Step 2 - Add user to src/constants.ts

export const USERS: User[] = [
  {
    rentalId: "1234-5678-910",
    preferedGroups: [42, 43, 44, 45, 46, 47, 48],
    mainEmail: "google.calendar.inviter.email@gmail.com",
    inviteEmails: ["this.is.your.email@gmail.com", "and.your.roommates@gmail.com"],
    lookahead: 5, // How many weeks to look ahead
  }
]

Step 3 - Login to the calendar email

Run yarn update <user-rental-id> to be prompted a single time to log in to the primary calendar email. This will create a certificate in the certs/ directory.

Deploy

Example git post-receive hook deployment script:

#!/bin/bash

deployDir="/home/user/builds/tvatt"

rm -rf $deployDir &&
mkdir $deployDir || exit

echo "Checkout out master"
export GIT_WORK_TREE=$deployDir
export GIT_DIR=$(pwd)
git checkout -f master

cd $deployDir

echo "Building"
docker build -t tvatt . || exit

echo "Shutting down old"
DATE=$(date +"%Y-%m-%d %T")
echo "[SHUTTING DOWN OLD INSTANCE: $DATE]" >> ~/logs/tvatt/out.log
docker stop tvatt-container
docker rm tvatt-container

echo "Running"
DATE=$(date +"%Y-%m-%d %T")
echo "[STARTING NEW INSTANCE: $DATE]" >> ~/logs/tvatt/out.log
nohup docker run --restart=always \
        -p 5100:80 \
        -e SQLITE_FILE='/logs/db.sqlite' \
        -v ~/logs/tvatt:/logs \
        --name tvatt-container \
        -t tvatt &>>~/logs/tvatt/out.log &

echo "Done"

Available commands

start runs the main server

update

book

update:day

About

Automatically scrape SSSB Laundry portal, upload laundry dates to Google Calendar and book via an intuitive user interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages