Git Product home page Git Product logo

f1next's Introduction

F1NEXT

A simple python script that prints the dates of the next Formula 1 Grand Prix. It uses Ergast API and includes cache to reduce API calls.

Example of output

Usage

Usage: f1next [OPTIONS]

  Simple script that shows you information about the next F1 Grand Prix

Options:
  -h, --help                 Show this message and exit.
  -f, --force-download       Force cache to be refreshed.
  -s, --schedule             Show the schedule for all events in the weekend.
  -c, --countdown            Show countdown to the next event
  -i, --circuit-information  Show circuit name and country
  -r, --color                Always printout colors and styling

f1next will print the name and date of the next Formula 1 Grand Prix.

Use the -f or --force-download flag to refresh the cache. The cache lasts for 6 hours, so information about the next Grand Prix might be wrong while another Grand Prix is taking place. This is normal even if your cache is up to date due to how the Ergast API work.

The -s or --schedule flag will print the full schedule for the weekend, instead of only showing the first and last dates. It uses local time as timezone.

The -c or --countdown flag will also print a countdown in days to the next event. If the event starts in less than 48 hours, it will also print hours and minutes left.

The -i or --circuit-information flag will print the race circuit name, city and country.

All the options can be used together in any combination and order, except for -h, --help.

f1next -sc
f1next -s
f1next -c
f1next -isc
f1nxt -si
f1next -s

All output options at the same time

The script uses click.echo() to print out information. If you pipe the output to a file, colors won't be included. To change this behaviour, include the -r / --color flag. It will always print out colors with ANSI escape code.

Piping to a file

Example of usage

If you are on KDE Plasma, you can use the command output widget to get the output as an HTML panel.

Command output usage

To keep the tables aligned while including colors, you need to change every whitespace to  :

    ~/.local/bin/f1next -scr | sed 's/ /\ /g'

Notes

This is a simple hobby project. My main goal was to get familiarity with python, click and git. Feel free to open an issue if you have any feedback or features suggestions.

TODO

  • Weekend Schedule
  • Countdown to closest event
  • Option to display more information about the GP
  • Change main function to facilitate testing
  • Publish on PyPI
  • Error handling:
    • API call errors
    • Can't find next event
    • Invalid cache
    • Last event is older than 24 hours

Possible features

  • Add -h shortcut for help message
  • Scheadule table with better formating
  • Include round number
  • Better color output (grey out past events)
  • Option to open the wikipedia link for the circuit/event
  • Emoji Flag

f1next's People

Contributors

ralacerda avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.