This program tries to book a tennis court slot in either Southwark Park or Tanner Street Park in Southwark, London.

Overview

Book tennis courts in London

This program tries to book a tennis court slot in either Southwark Park or Tanner Street Park in Southwark, London.

Note: Unfortunately, starting from November 1st 2021, tennis courts in Southwark won't be allowed to be booked for free anymore, and will require a card payment at the moment of booking. I haven't updated the script to reflect this, nor I plan to, hence effectively this script is deprecated (it will throw an exception at some point during the booking phase). I have published this repository nonetheless as an example, since it can be adapted for other booking systems with the appropriate modifications.

Table of Contents

  1. Overview
  2. Usage
  3. Some Examples

Overview

The program is made of one main file, book_tennis_court.py, which uses functions from helper.py and data from constants.py.

book_tennis_court.py can be run directly from the command line by invoking the python interpreter. It takes 3 argument:

  • times (positional arguments): indicate when (at what time) we want to book the court for
    • must be expressed in the form hour:minute (e.g. 8:00)
    • can be as many as you like (in case we have more than one option that works for us and we want to maximise the probability of finding an available court)
  • --date (or -d): the day we want to book the court for
    • can be expressed in absolute terms (in the form yyyy-mm-dd) or in relative terms (from 0 to 7), in which case it would indicate the day falling xdays in the future
    • accepts only 1 value
  • --wait (or -w): used to let the script know if we want to run it immediately or stop execution until a given time
    • can be no (if we want to run the entire script immediately) or in the form hour:minute:second (e.g. 20:0:0 (8pm))
    • accepts only 1 value

Usage

python book_tennis_court.py [-h] [--date [DATE]] [--wait [WAIT]] [times]

A help message can be displayed by typing: python book_tennis_court.py -h, which results in the message below appearing to the screen:

positional arguments:
times:  {8:00,8:30,9:00,9:30,10:00,10:30,11:00,11:30,12:00,12:30,13:00,13:30,14:00,
14:30,15:00,15:30,16:00,16:30,17:00,17:30,18:00,18:30,19:00,19:30,20:00,20:30}
                        The times that the script will try to book

optional arguments:
  -h, --help    show this help message and exit
  --date [DATE], -d [DATE]
                        The date that the script will try to book. Can be a
                        date, in which case it needs to be in the form 'yyyy-
                        mm-dd', or an integer, in which case it will indicate
                        the day falling 'date' days in the future.
                        Defaults to 7 (i.e. the day falling one week in the future)
  --wait [WAIT], -w [WAIT]
                        The time that the script will wait until making the
                        booking. Can either be 'no' (if we want to book
                        immediately) or be expressed in 'hour:minute:second').
                        Defaults to '20:0:0' (8pm)

Some Examples

Basic example

The booking system opens at 8pm each day for the day falling one week in the future. So, assuming we are on a Saturday (before 8pm!), the following command will make the script to book a slot at 4.00pm for the following Saturday:

python book_tennis_court.py 16:00

This is because the default values for --date and --wait are 7 (i.e., 7 days in the future) and 20:0:0 (i.e., 8pm) respectively.

Second example

Let's now assume we are on a Friday and would like to play the next day, but all courts have been booked. The only thing we can do is to hope that someone cancels their booking and book it ourselves - however free slots usually disappear really soon, so we need to keep checking and checking and checking!

We can authomate this by having our script run every, say, 5 minutes, which will check if a booking has been cancelled, in which case it will book it for us! Assuming we are free to play anytime between 9am and 11.30am (i.e. the last full hour would be from 10:30 to 11:30), the correct command would be:

python book_tennis_court.py 9:00 9:30 10:00 10:30 -w no -d 1

We can then make it run every 5 minutes with, for example, the cron utility (on Linux and MacOS) and hope that someone indeed cancel their booking :).

If we want to keep our script running overnight (so that past midnight it will need to try and book for the same day, not the day after), we should specify the date as follows (let's assume today is 26th October 2021):

python book_tennis_court.py 9:00 9:30 10:00 10:30 -w no -d 2021-10-27

Owner
Daniele
Daniele
Recreating my first CRUD in python, but now more professional

Recreating my first CRUD in python, but now more professional

Ricardo Deo Sipione Augusto 2 Nov 27, 2021
Make discord server By Coding!

Discord Server Maker Make discord server by Coding! FAQ How can i get role permissons? Open discord with chrome developer tool, go to network and clic

1 Jul 17, 2022
It's like Forth but in Python

It's like Forth but written in Python. But I don't actually know for sure since I never programmed in Forth, I only heard that it's some sort of stack-based programming language. Porth is also stack-

Tsoding 619 Dec 21, 2022
A pure-Python codified rant aspiring to a world where numbers and types can work together.

Copyright and other protections apply. Please see the accompanying LICENSE file for rights and restrictions governing use of this software. All rights

Matt Bogosian 28 Sep 04, 2022
Automate your Microsoft Learn Student Ambassadors event certificate with Python

Microsoft Learn Student Ambassador Certificate Automation This repo simply use a template certificate docx file and generates certificates both docx a

Muhammed Oğuz 24 Aug 24, 2022
AdventOfCode 2021 solutions from the Devcord server

adventofcode-21 Ein Sammel-Repository für Advent of Code 2021-Lösungen der deutschen DevCord-Community. A repository collecting Advent of Code 2021 so

Devcord 12 Aug 26, 2022
PyDy, short for Python Dynamics, is a tool kit written in the Python

PyDy, short for Python Dynamics, is a tool kit written in the Python programming language that utilizes an array of scientific programs to enable the study of multibody dynamics. The goal is to have

PyDy 307 Jan 01, 2023
This repository contains code for building education startup.

Learning Management System Overview It's the code for EssayBrain, a tool for teacher that automatically grades and validates essays. In order to valid

Shyam Das Shrestha 1 Nov 21, 2021
Powerful virtual assistant in python

Virtual assistant in python Powerful virtual assistant in python Set up Step 1: download repo and unzip Step 2: pip install requirements.txt (if py au

Arkal 3 Jan 23, 2022
JupyterLite as a Datasette plugin

datasette-jupyterlite JupyterLite as a Datasette plugin Installation Install this plugin in the same environment as Datasette. $ datasette install dat

Simon Willison 11 Sep 19, 2022
AHP Calculator - A method for organizing and evaluating complicated decisions, using Maths and Psychology

AHP Calculator - A method for organizing and evaluating complicated decisions, using Maths and Psychology

16 Aug 08, 2022
LPCV Winner Solution of Spring Team

LPCV Winner Solution of Spring Team

22 Jul 20, 2022
Allows you to purge all reply comments left by a user on a YouTube channel or video.

YouTube Spammer Purge Allows you to purge all reply comments left by a user on a YouTube channel or video. Purpose Recently, there has been a massive

4.3k Jan 09, 2023
NCAR/UCAR virtual Python Tutorial Seminar Series lesson on MetPy.

The Project Pythia Python Tutorial Seminar Series continues with a lesson on MetPy on Wednesday, 2 February 2022 at 1 PM Mountain Standard Time.

Project Pythia Tutorials 6 Oct 09, 2022
Web站点选优工具 - 优化GitHub的打开速度、高效Clone

QWebSiteOptimizer - Web站点速度选优工具 在访问GitHub等网站时,DNS解析到的IP地址可能并不是最快,过慢的节点会严重影响我们的访问情况,故制作出这样的工具来进一步优化网络质量。 由于该方案并非为VPN等方式进行的速度优化,以下几点需要您注意: 后续访问对应网站时仍可能需

QPT Family 15 May 01, 2022
Student Result Management System Project in tkinter created based on python, tkinter, and SQLITE3 Database

Student-Result-Management-System This Student Result Management System Project in tkinter created based on python, tkinter, and SQLITE3 Database. The

Ravi Chauhan 2 Aug 03, 2022
Viewflow is an Airflow-based framework that allows data scientists to create data models without writing Airflow code.

Viewflow Viewflow is a framework built on the top of Airflow that enables data scientists to create materialized views. It allows data scientists to f

DataCamp 114 Oct 12, 2022
Used the pyautogui library to automate some processes on the computer

Pyautogui Utilizei a biblioteca pyautogui para automatizar alguns processos no c

Dheovani Xavier 1 Dec 30, 2021
App to get data from popular polish pages with job offers

Job board parser I written simple app to get me data from popular pages with job offers, because I wanted to knew immidietly if there is some new offe

0 Jan 04, 2022
Python Cheat Sheet

Introduction Pysheeet was created with intention of collecting python code snippets for reducing coding hours and making life easier and faster. Any c

CHANG-NING TSAI 7.5k Dec 30, 2022