Esempio n. 1
0
def main():
    fr = flightradar24.Api()
    flight = fr.get_flight('CZ300')

    flight_id = flight['result']['response']['data'][0]['identification']['id']
    timestamp = flight['result']['response']['timestamp']

    json_file = get_json(flight_id, timestamp)
    coordinates = parse_coordinates(json_file)

    draw_the_flight(coordinates)
Esempio n. 2
0
def main():
	fr24 = flightradar24.Api()
	# getGlobalAirlines(fr24)
	# print(getAirlines())

	getGlobalFlights(fr24)
	# getGlobalFlight(fr24, "AFL")

	for line in findByСoordinate("56.3268 44.0059"):
		flight = parse.flight_information(line)
		print(line)
		print(flight.height)
Esempio n. 3
0
def get_airline_flights(airline_code):
    fr = flightradar24.Api()
    flights_data = fr.get_flights(airline_code)
    flights = []

    for key, value in flights_data.items():
        if isinstance(value, list):
            flight_dict = {
                "airline": airline_code,
                "from": value[11],
                "to": value[12],
                "aircraft": value[8]
            }
            flights.append(flight_dict)

    return flights
Esempio n. 4
0
def getflight():
    air = []
    airline = 'BAW'
    fr = flightradar24.Api()
    flights = fr.get_flights(airline)
    data = list(flights.values())
    x = 2
    while x >= 2:
        x = x + 1
        data1 = data[x][11:14]
        air.append(data1)
        df = pd.DataFrame(air)
        df.to_csv('flights.csv', index=False)
        print(data1)

    return flights
Esempio n. 5
0
def main():
    fr24 = flightradar24.Api()

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # sock.bind( ("192.168.1.111", 777) )
    sock.bind(("", 777))
    sock.listen(5)
    while 1:
        conn, addr = sock.accept()
        data = conn.recv(16384)
        udata = data.decode("utf-8")

        user_info = parse.user_tcp(udata)
        answer = []

        if (user_info.ERROR != True):

            if (user_info.command == user_info.commands["FlightsByCoordinates"]
                ):
                answer = flights.findByСoordinate(
                    str(user_info.coordinate1) + " " +
                    str(user_info.coordinate2))

            if (user_info.command == user_info.commands["FlightsByAirlines"]):
                for airline in user_info.airlines:
                    flights.getGlobalFlight(fr24, airline)
                    answer += file.readLines(config.flights_dir + airline)
        else:
            answer = ["error"]

        answer_string = ""
        for answer_one in answer:
            answer_string += answer_one + "\n"

        conn.send(bytes(answer_string, 'utf-8'))
        conn.close()
Esempio n. 6
0
import flightradar24
import json
# import pandas as pd

flight_id = 'HD12'
fr = flightradar24.Api()
flight = fr.get_flight(flight_id)

print(json.dumps(flight, indent=2))
Esempio n. 7
0
def get_all_airlines():
    fr = flightradar24.Api()
    airlines = fr.get_airlines()
    return airlines['rows']
Esempio n. 8
0
def get_all_airports():
    fr = flightradar24.Api()
    airports = fr.get_airports()
    return airports['rows']
Esempio n. 9
0
def rawFlightList():
    fr = flightradar24.Api()
    alaskaAirlinesCode = 'ASA'
    hawaiianAirlinesCode = 'HAL'
    southwestAirlinesCode = 'SWA'
    jetblueAirwaysCode = 'JBU'
    deltaAirlinesCode = 'DAL'
    frontierAirlinesCode = 'FFT'
    spiritAirlinesCode = 'NKS'
    americanAirlinesCode = 'AAL'
    unitedAirlinesCode = 'UAL'

    alaskaFlights = fr.get_flights(alaskaAirlinesCode)
    alaskaHeaders = []
    for i in alaskaFlights:
        alaskaHeaders.append(i)
    alaskaHeaders.pop()
    alaskaHeaders.pop(0)
    alaskaHeaders.pop(0)

    alaskaData = []
    for x in range(len(alaskaHeaders)):
        alaskaData.append(alaskaFlights[alaskaHeaders[x]])

    hawaiiFlights = fr.get_flights(hawaiianAirlinesCode)
    hawaiiHeaders = []
    for i in hawaiiFlights:
        hawaiiHeaders.append(i)
    hawaiiHeaders.pop()
    hawaiiHeaders.pop(0)
    hawaiiHeaders.pop(0)

    hawaiiData = []
    for x in range(len(hawaiiHeaders)):
        hawaiiData.append(hawaiiFlights[hawaiiHeaders[x]])

    southewestFlights = fr.get_flights(southwestAirlinesCode)
    southwestHeaders = []
    for i in southewestFlights:
        southwestHeaders.append(i)
    southwestHeaders.pop()
    southwestHeaders.pop(0)
    southwestHeaders.pop(0)

    southwestData = []
    for x in range(len(southwestHeaders)):
        southwestData.append(southewestFlights[southwestHeaders[x]])

    jetblueFlights = fr.get_flights(jetblueAirwaysCode)
    jetblueHeaders = []
    for i in jetblueFlights:
        jetblueHeaders.append(i)
    jetblueHeaders.pop()
    jetblueHeaders.pop(0)
    jetblueHeaders.pop(0)

    jetblueData = []
    for x in range(len(jetblueHeaders)):
        jetblueData.append(jetblueFlights[jetblueHeaders[x]])

    deltaFlights = fr.get_flights(deltaAirlinesCode)
    deltaHeaders = []
    for i in deltaFlights:
        deltaHeaders.append(i)
    deltaHeaders.pop()
    deltaHeaders.pop(0)
    deltaHeaders.pop(0)

    deltaData = []
    for x in range(len(deltaHeaders)):
        deltaData.append(deltaFlights[deltaHeaders[x]])

    frontierFlights = fr.get_flights(frontierAirlinesCode)
    frontierHeaders = []
    for i in frontierFlights:
        frontierHeaders.append(i)
    frontierHeaders.pop()
    frontierHeaders.pop(0)
    frontierHeaders.pop(0)

    frontierData = []
    for x in range(len(frontierData)):
        frontierData.append(frontierFlights[frontierHeaders[x]])

    spiritFlights = fr.get_flights(spiritAirlinesCode)
    spiritHeaders = []
    for i in spiritFlights:
        spiritHeaders.append(i)
    spiritHeaders.pop()
    spiritHeaders.pop(0)
    spiritHeaders.pop(0)

    spiritData = []
    for x in range(len(spiritHeaders)):
        spiritData.append(spiritFlights[spiritHeaders[x]])

    americanFlights = fr.get_flights(americanAirlinesCode)
    americanHeaders = []
    for i in americanFlights:
        americanHeaders.append(i)
    americanHeaders.pop()
    americanHeaders.pop(0)
    americanHeaders.pop(0)

    americanData = []
    for x in range(len(americanHeaders)):
        americanData.append(americanFlights[americanHeaders[x]])

    unitedFlights = fr.get_flights(unitedAirlinesCode)
    unitedHeaders = []
    for i in unitedFlights:
        unitedHeaders.append(i)
    unitedHeaders.pop()
    unitedHeaders.pop(0)
    unitedHeaders.pop(0)

    unitedData = []
    for x in range(len(unitedHeaders)):
        unitedData.append(unitedFlights[unitedHeaders[x]])

    return alaskaData, hawaiiData, southwestData, jetblueData, deltaData, frontierData, spiritData, americanData, unitedData
Esempio n. 10
0
async def get_flights_by_company(company):
    """
    Args:

    Returns:

    """
    try:
        data = flightradar24.Api()
        flights_data = data.get_flights(company)

        ignore = ['version', 'total', 'full_count', 'stats']
        for item in flights_data:
            if item not in ignore:
                flight_infos = flights_data[item]
                callsign = flight_infos[16]
                aircraft = flight_infos[8]
                count_exist = len(RESULT_LIST[callsign])
                try:
                    infos = data.get_flight(flight_infos[13])

                    for item in infos['result']['response']['data']:
                        today = datetime.utcnow().strftime("%Y-%m-%d")
                        flightdate = datetime.utcfromtimestamp(
                            item['time']['scheduled']['departure']).strftime(
                                '%Y-%m-%d')
                        if flightdate == today and callsign != '':
                            dep_position = defaultdict(list)
                            arr_position = defaultdict(list)
                            dep_icao = item['airport']['origin']['code'][
                                'icao']
                            arr_icao = item['airport']['destination']['code'][
                                'icao']
                            dep_time = item['time']['scheduled']['departure']
                            arr_time = item['time']['scheduled']['arrival']

                            dep_position[dep_icao].append({
                                'latitude':
                                item['airport']['origin']['position']
                                ['latitude'],
                                'longitude':
                                item['airport']['origin']['position']
                                ['longitude']
                            })
                            arr_position[arr_icao].append({
                                'latitude':
                                item['airport']['destination']['position']
                                ['latitude'],
                                'longitude':
                                item['airport']['destination']['position']
                                ['longitude']
                            })

                            if count_exist == 0:
                                RESULT_LIST[callsign].append({
                                    'origin':
                                    dep_position,
                                    'destination':
                                    arr_position,
                                    'aircraft':
                                    aircraft,
                                    'dep_time':
                                    datetime.utcfromtimestamp(
                                        dep_time).strftime('%Y-%m-%d %H:%M'),
                                    'arr_time':
                                    datetime.utcfromtimestamp(
                                        arr_time).strftime('%Y-%m-%d %H:%M')
                                })
                            else:
                                RESULT_LIST[callsign].clear()
                                RESULT_LIST[callsign].append({
                                    'origin':
                                    dep_position,
                                    'destination':
                                    arr_position,
                                    'aircraft':
                                    aircraft,
                                    'dep_time':
                                    datetime.utcfromtimestamp(
                                        dep_time).strftime('%Y-%m-%d %H:%M'),
                                    'arr_time':
                                    datetime.utcfromtimestamp(
                                        arr_time).strftime('%Y-%m-%d %H:%M')
                                })

                except:
                    pass

    except:
        pass

    return RESULT_LIST
Esempio n. 11
0
def rawFlightList():
    fr = flightradar24.Api()
    airlines = fr.get_airlines()
    alaskaAirlinesCode = 'ASA'
    hawaiianAirlinesCode = 'HAL'
    southwestAirlinesCode = 'SWA'
    jetblueAirwaysCode = 'JBU'
    deltaAirlinesCode = 'DAL'
    frontierAirlinesCode = 'FFT'
    spiritAirlinesCode = 'NKS'
    americanAirlinesCode = 'AAL'
    unitedAirlinesCode = 'UAL'

    alaskaFlights = fr.get_flights(alaskaAirlinesCode)
    hawaiianFlights = fr.get_flights(hawaiianAirlinesCode)
    southwestFlights = fr.get_flights(southwestAirlinesCode)
    jetblueFlights = fr.get_flights(jetblueAirwaysCode)
    deltaFlights = fr.get_flights(deltaAirlinesCode)
    frontierFlights = fr.get_flights(frontierAirlinesCode)
    spiritFlights = fr.get_flights(spiritAirlinesCode)
    americanFlights = fr.get_flights(americanAirlinesCode)
    unitedFlights = fr.get_flights(unitedAirlinesCode)

    alaskaFlightList = []
    for i in alaskaFlights.values():
        alaskaFlightList.append(i)

    hawaiianFlightList = []
    for i in hawaiianFlights.values():
        hawaiianFlightList.append(i)

    southwestFlightList = []
    for i in southwestFlights.values():
        southwestFlightList.append(i)

    jetblueFlightList = []
    for i in jetblueFlights.values():
        jetblueFlightList.append(i)

    deltaFlightList = []
    for i in deltaFlights.values():
        deltaFlightList.append(i)

    frontierFlightList = []
    for i in frontierFlights.values():
        frontierFlightList.append(i)

    spiritFlightList = []
    for i in spiritFlights.values():
        spiritFlightList.append(i)

    americanFlightList = []
    for i in americanFlights.values():
        americanFlightList.append(i)

    unitedFlightList = []
    for i in unitedFlights.values():
        unitedFlightList.append(i)

    for x in range(0, 2):
        alaskaFlightList.pop(0)
        hawaiianFlightList.pop(0)
        southwestFlightList.pop(0)
        jetblueFlightList.pop(0)
        deltaFlightList.pop(0)
        frontierFlightList.pop(0)
        spiritFlightList.pop(0)
        americanFlightList.pop(0)
        unitedFlightList.pop(0)
    alaskaFlightList.pop()
    hawaiianFlightList.pop()
    southwestFlightList.pop()
    jetblueFlightList.pop()
    deltaFlightList.pop()
    frontierFlightList.pop()
    spiritFlightList.pop()
    americanFlightList.pop()
    unitedFlightList.pop()

    finalDict = {
        'alaska': alaskaFlightList,
        'hawaiian': hawaiianFlightList,
        'southwest': southwestFlightList,
        'jetblue': jetblueFlightList,
        'delta': deltaFlightList,
        'frontier': frontierFlightList,
        'spirit': spiritFlightList,
        'american': americanFlightList,
        'united': unitedFlightList
    }


    return alaskaFlightList, hawaiianFlightList, southwestFlightList, jetblueFlightList, deltaFlightList, \
           frontierFlightList, spiritFlightList, americanFlightList, unitedFlightList
Esempio n. 12
0
import flightradar24

fr24api = flightradar24.Api()


def get_ground_speed(flight_icao, airline_icao):
    flights = fr24api.get_flights(airline_icao)

    for i in flights:
        flight = flights[i]
        if isinstance(flight, list) == True:
            if flight[16] == flight_icao:
                return flight[5]

    return 0
Esempio n. 13
0
def getmaphtml(flight_id=airplane_id):
    s = str("")
    if flight_id == '':
        s = str("""<html><head><style>h3{margin-top: 20px;}</style></head><body><h3>Plane not selected</h3></body></html>""")
    else:
        fr = flightradar24.Api()

        flight = fr.get_flight(flight_id) # getting data like flight.json
        # print(flight)
        flightData = flight["result"]["response"]["data"]
        if flightData != None:
            livePlanes = [plane for plane in flightData if plane["status"]["live"]]
            livePlanesId = [plane["identification"]["id"] for plane in livePlanes]
            livePlanesAirline = [plane["airline"]["code"]["icao"] for plane in livePlanes]
            # print(livePlanes)
            print("Live planes: " + str(len(livePlanes)))

            if len(livePlanes) > 0:
                print("Plane id: " + livePlanesId[0])
                print("Airline: " + livePlanesAirline[0])
                flights = fr.get_flights(livePlanesAirline[0]) # getting data like flights.json
                # print(flights)
                planeLat = flights[livePlanesId[0]][1]
                planeLng = flights[livePlanesId[0]][2]
                planeAngle = flights[livePlanesId[0]][3]
                planeAltitude = flights[livePlanesId[0]][4]
                planeSpeed = flights[livePlanesId[0]][5]
                print("Latitude: " + str(planeLat) + " Longitude: " + str(planeLng) + " Speed: " + str(
                    round(planeSpeed * 1.852)) + "(km/h) Altitude: " + str(round(planeAltitude / 3281, 3)) + "km")

                s = str("""<html>
                  <head>
                    <style>
                      /* Set the size of the div element that contains the map */
                      #map {
                        height: 100%;  /* The height is 400 pixels */
                        width: 100%;  /* The width is the width of the web page */
                       }
                    </style>
                  </head>
                  <body>
                    <!--The div element for the map -->
                    <div id="map"></div>
                    <script>
                // Initialize and add the map
                function initMap() {
                  // The location of airplane
                  var plane = {lat: """ + str(planeLat) + """, lng: """ + str(planeLng) + """};
                  // The map, centered at plane
                  var map = new google.maps.Map(
                      document.getElementById('map'), {zoom: 5, center: plane});
                  // The marker, positioned at plane
                  var icon = {
                    // url: "https://ru.seaicons.com/wp-content/uploads/2015/08/Airplane-Top-Red-icon.png", // url
                    path: 'M 22 16 v -2 l -8.5 -5 V 3.5 C 13.5 2.67 12.83 2 12 2 s -1.5 0.67 -1.5 1.5 V 9 L 2 14 v 2 l 8.5 -2.5 V 19 L 8 20.5 L 8 22 l 4 -1 l 4 1 l 0 -1.5 L 13.5 19 v -5.5 L 22 16 Z',
                    fillColor: '#F00',
                    fillOpacity: 1,
                    // scaledSize: new google.maps.Size(64, 64), // scaled size
                    // origin: new google.maps.Point(0,0), // origin
                    anchor: new google.maps.Point(11, 8), // anchor
                    rotation: """ + str(planeAngle) + """,
                    scale: 1
                };
    
                  var marker = new google.maps.Marker({position: plane, map: map, icon: icon, title: "Plane is here!", label: "Plane"});
                }
                    </script>
                    <script async defer
                    src="https://maps.googleapis.com/maps/api/js?key=""" + str(api_key) + """&callback=initMap">
                    </script>
                  </body>
                </html>""")
            else:
                s = str("""<html><head><style>h3{margin-top: 20px;}</style></head><body><h3>Plane is offline</h3></body></html>""")
        else:
            s = str("""<html><head><style>h3{margin-top: 20px;}</style></head><body><h3>Can't find plane</h3></body></html>""")
    return s