Show list of past and upcoming flights. Data is read from OpenFlights backup.
Find a file
2023-09-29 08:18:47 +01:00
flights Add backup script, README and LICENSE 2023-09-29 08:13:27 +01:00
LICENSE Add backup script, README and LICENSE 2023-09-29 08:13:27 +01:00
README.md Add sample output to README 2023-09-29 08:18:47 +01:00
run_backup Add backup script, README and LICENSE 2023-09-29 08:13:27 +01:00

Flight History Backup and Display Scripts

Introduction

These Python scripts allow you to automate the process of downloading and displaying your flight history from OpenFlights. You can use the backup script to regularly download a CSV backup of your flight data, and the display script to list your past and future flights. This README will guide you through setting up and using these scripts.

Prerequisites

Before you begin, make sure you have the following requirements installed:

  • Python 3.x
  • Playwright for web automation (used by the backup script)

Installation

  1. Clone or download this repository to your local machine.

    git clone https://git.4angle.com/edward/flights.git
    
  2. Install the required Python modules for the scripts.

    pip install playwright
    
  3. Create a configuration file for your OpenFlights account. You can use the provided sample config file as a template (config). Update the username and password fields with your OpenFlights login credentials.

    [backup]
    backup_dir=/path/to/backup/directory
    username=YourOpenFlightsUsername
    password=YourOpenFlightsPassword
    
    [history]
    days=120
    

Usage

Backup Script (run_backup)

The backup script automates the process of downloading a CSV backup of your flight history from OpenFlights. You can schedule this script to run periodically, such as daily using cron.

  1. Open your terminal and navigate to the directory where you cloned or downloaded the scripts.

  2. Run the backup script:

    python run_backup.py
    

    This script will launch a headless browser, log in to your OpenFlights account, and download the CSV backup to the specified directory in your configuration file.

  3. You can schedule this script to run daily using cron or any other scheduling tool. For example, to run it every day at 2 AM, add the following line to your crontab:

    0 2 * * * /usr/bin/python3 /path/to/openflights-scripts/run_backup
    

Display Script (flights)

The display script reads the downloaded CSV backup and displays a list of your past and future flights within a specified date range.

  1. Open your terminal and navigate to the directory where you cloned or downloaded the scripts.

  2. Run the display script:

    python flights
    

    This script will read the most recent CSV backup file in the specified directory, filter flights based on the configured date range, and display the results.

Sample Output

Here is an example of the output you can expect from the display script:

  Tue, 27 Jun 2023   94 days ago  LHR  -> TIA   03:05   British Airways  BA926    C    1A  G-EUYB  Airbus A320-232
  Sat, 01 Jul 2023   90 days ago  TIA  -> LHR   03:05   British Airways  BA929    C    3A  G-EUUR  Airbus A320-232
  ...
  Sun, 17 Sep 2023   12 days ago  DOH  -> LHR   07:20     Qatar Airways  QR15     C    1K  A7-BAF  Boeing 777-300ER
  Tue, 14 Nov 2023       46 days  LHR  -> MAD   02:30   Iberia Airlines  IB3173   Y   12A          Airbus A320
  Tue, 14 Nov 2023       46 days  MAD  -> MVD   11:56   Iberia Airlines  IB6011   Y   41A          Airbus A330-200
  Mon, 20 Nov 2023       52 days  MVD  -> MAD   12:55   Iberia Airlines  IB6012   C    2A          Airbus A330-200
  Tue, 21 Nov 2023       52 days  MAD  -> LHR   02:35   Iberia Airlines  IB3162   C    4A          Airbus A330

Customization

You can customize the scripts further by modifying the configuration file (config) or the scripts themselves. For example, you can adjust the number of days to look back for past flights or customize the display format.

License

This project is licensed under the MIT License - see the LICENSE file for details.