Show list of past and upcoming flights. Data is read from OpenFlights backup.
Find a file
2023-09-29 08:13:27 +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 backup script, README and LICENSE 2023-09-29 08:13:27 +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.

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.