inflight-status

Inflight Internet Stauts Helper Scripts
git clone git://r-36.net/inflight-status
Log | Files | Refs | README | LICENSE

commit 44b0cfc4cca7eb08ebf979dd1a58af88233aa80a
parent 38fe7eb1486a54050b040316a67f93ba75d43b5d
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 27 May 2023 19:05:56 +0200

Add Emirates stub.

Emirates sucks at getting us a proper flight status. Only amateurs use
bootstrap. The web sucks.

Diffstat:
Minflight-status | 45++++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/inflight-status b/inflight-status @@ -8,7 +8,8 @@ import os import sys import getopt -from lxml import html +from lxml import etree +import io import requests from terminaltables import SingleTable as Table @@ -26,11 +27,13 @@ def main(args): flightdatauris = { "panasonic": "http://services.inflightpanasonic.aero/inflight/services/flightdata/v1/flightdata", - "airfrance": "https://connect.airfrance.com/ach/api/flightdata" + "airfrance": "https://connect.airfrance.com/ach/api/flightdata", + "emirates": "https://portal.inflight.onair.aero/ac/UAE/en/connect" } useproxy = False dotable = True + nnfd = {} for o, a in opts: if o == "-h": usage(args[0]) @@ -59,9 +62,8 @@ def main(args): if statustype == None: return 1 - flightdata = fd.json() - if statustype == "panasonic": + flightdata = fd.json() tablehdr = "flight %s from %s to %s" % ( flightdata["td_id_fltdata_flight_number"], flightdata["td_id_fltdata_departure_baggage_id"], @@ -80,6 +82,7 @@ def main(args): del nfd elif statustype == "airfrance": + flightdata = fd.json() tablehdr = "flight %s from %s to %s" % ( flightdata["flight"]["number"], flightdata["flight"]["originIATA"], @@ -99,21 +102,25 @@ def main(args): nnfd = lineardict(flightdata) - nnfdkeys = list(nnfd.keys()) - nnfdkeys.sort() - if dotable == True: - print(tablehdr) - tabledata = [["key", "value"]] - for k in nnfdkeys: - tabledata.append([k, nnfd[k]]) - - table = Table(tabledata, tablehdr) - table.outer_border = False - print(table.table) - else: - print(tablehdr) - for k in nnfdkeys: - print("%s: %s" % (k, nnfd[k])) + elif statustype == "emirates": + tablehdr = "Emirates sucks at doing proper flight status." + + if nnfd != None: + nnfdkeys = list(nnfd.keys()) + nnfdkeys.sort() + if dotable == True: + print(tablehdr) + tabledata = [["key", "value"]] + for k in nnfdkeys: + tabledata.append([k, nnfd[k]]) + + table = Table(tabledata, tablehdr) + table.outer_border = False + print(table.table) + else: + print(tablehdr) + for k in nnfdkeys: + print("%s: %s" % (k, nnfd[k])) return 0