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

You might also like...
Simple python code for compile brainfuck program.

py-brainf*ck Just a basic compiled that compiles your brainf*ck codes and gives you informations about memory, used cells, dumped version, logs etc...

Dyson Sphere Program Blueprint Toolkit

dspbptk This is dspbptk, the Dyson Sphere Program Blueprint toolkit. Dyson Sphere Program is an amazing factory-building game by the incredibly talent

This program is meant to take the pain out of generating nice bash PS1 prompts.
This program is meant to take the pain out of generating nice bash PS1 prompts.

TOC PS1 Installation / Quickstart License Other Docs Examples PS1 Command Help PS1 ↑ This program is meant to take the pain out of generating nice bas

A practice program to find the LCM i.e Lowest Common Multiplication of two numbers using python without library.

Finding-LCM-using-python-from-scratch Here, I write a practice program to find the LCM i.e Lowest Common Multiplication of two numbers using python wi

 This module is for finding the execution time of a whole python program
This module is for finding the execution time of a whole python program

exetime 3.8 This module is for finding the execution time of a whole program How to install $ pip install exetime Contents: General Information Instru

Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems.
Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems.

Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems. Packer supports Python 🐍 , C 💻 and C++ 💻 libraries.

Change your Windows background with this program safely &  easily!
Change your Windows background with this program safely & easily!

Background_Changer Table of Contents: About the Program Features Requirements Preview Credits Reach Me See Also About the Program: You can change your

An Notifier Program that Notifies you to relax your eyes Every 15 Minutes👀
An Notifier Program that Notifies you to relax your eyes Every 15 Minutes👀

Every 15 Minutes ⌛ Every 15 Minutes is an application that is used to Notify you to Relax your eyes Every 15 Minutes, This is fully made with Python a

This is a program for Carbon Emission calculator.
This is a program for Carbon Emission calculator.

Summary This is a program for Carbon Emission calculator. Usage This will calculate the carbon emission by each person on various factors. Contributor

Owner
Daniele
Daniele
The parser of a timetable of tennis matches for Flashscore website

FlashscoreParser The parser of a timetable of tennis matches for Flashscore website. The program collects the schedule of tennis matches for two days

Valendovsky 1 Jul 15, 2022
emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

emoji-math computes the given python expression and returns either the value or the nearest 5 emojis as measured by cosine similarity.

Andrew White 13 Dec 11, 2022
This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator

Late-Bound Arguments This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator. Usage Mention the names of the argumen

Shakya Majumdar 0 Feb 6, 2022
FCurve-Cleaner: Tries to clean your dense mocap graphs like an animator would

Tries to clean your dense mocap graphs like an animator would! So it will produce a usable artist friendly result while maintaining the original graph.

wiSHFul97 5 Aug 17, 2022
A Python Web Application for Checking vaccine slots by pincodes and auto slot booking.

The Dashboard is developed using Bokeh and python 3.5+. This dashboard is useful for you if you are looking for something which will help you to book the vaccine slot once slots become available. Other Vaccine Finders will notify you once slots become available but you will still need to login to the portal and book the slot manually. This dashboard will look for slot availability continuously and will send the OTP itself once slots become available.

Suraj Deshmukh 10 Jan 23, 2022
That is a example of a Book app on Python, made with support of all JS libraries on React framework

React+Python Books App You can use this repository whenever you want Used for a video Create the database: python -m dbutils Start the web server: pyt

Koma Human 1 Apr 20, 2022
Open source book about making Python packages.

Python packages Tomas Beuzen & Tiffany Timbers Python packages are a core element of the Python programming language and are how you create organized,

Python Packages 169 Jan 6, 2023
This program generates automatically new folders containing old version of program

Automated Folder Versions Generator by Sergiy Grimoldi - V.0.0.2 This program generates automatically new folders containing old version of something

Sergiy Grimoldi 1 Dec 23, 2021
Birthday program - A program that lookups a birthday txt file and compares to the current date to check for birthdays

Birthday Program This is a program that lookups a birthday txt file and compares

Daquiver 4 Feb 2, 2022
This program goes thru reddit, finds the most mentioned tickers and uses Vader SentimentIntensityAnalyzer to calculate the ticker compound value.

This program goes thru reddit, finds the most mentioned tickers and uses Vader SentimentIntensityAnalyzer to calculate the ticker compound value.

null 195 Dec 13, 2022