Open
Description
Hello,
I'm using get_flights
with round-trip
and it doesn't seem to return what a normal round trip should represent.
Code
for from_airport in departure_airports:
for to_airport in arrival_airports:
for ret_date in return_dates:
flight_data = [
FlightData(
date=departure_date,
from_airport=from_airport,
to_airport=to_airport
),
FlightData(
date=ret_date,
from_airport=to_airport,
to_airport=from_airport
)
]
try:
result: Result = get_flights(
flight_data=flight_data,
trip="round-trip",
seat="economy",
passengers=passengers,
fetch_mode="fallback",
)
flight_dicts = [
{**flight.__dict__, "departure_airport": from_airport, "arrival_airport": to_airport}
for flight in result.flights
]
raw_flight_data.append(flight_dicts)
except Exception as e:
print(f"[WARN] Impossible de récupérer les vols pour {from_airport} -> {to_airport} ({departure_date} / {ret_date}), erreur : {e}")
continue
with open(json_file_path, "w") as json_file:
json.dump(raw_flight_data, json_file, indent=4)
Actual result
{
"is_best": true,
"name": "Ryanair",
"departure": "9:50 AM on Wed, Feb 5",
"arrival": "11:05 AM on Wed, Feb 5",
"arrival_time_ahead": "",
"duration": "2 hr 15 min",
"stops": 0,
"delay": null,
"price": "$48",
"departure_airport": "BVA",
"arrival_airport": "OPO"
},
{
"is_best": true,
"name": "Ryanair",
"departure": "9:45 PM on Wed, Feb 5",
"arrival": "11:00 PM on Wed, Feb 5",
"arrival_time_ahead": "",
"duration": "2 hr 15 min",
"stops": 0,
"delay": null,
"price": "$61",
"departure_airport": "BVA",
"arrival_airport": "OPO"
},
{
"is_best": true,
"name": "Self transferThis trip includes tickets from multiple airlines. Missed connections may be protected by the booking provider.",
"departure": "9:15 AM on Wed, Feb 5",
"arrival": "8:50 AM on Thu, Feb 6",
"arrival_time_ahead": "+1",
"duration": "24 hr 35 min",
"stops": 2,
"delay": null,
"price": "$200",
"departure_airport": "BVA",
"arrival_airport": "OPO"
},
Expected result
{
"is_best": true,
"name_outbound": "Ryanair",
"departure_outbound": "9:50 AM on Wed, Feb 5",
"arrival_outbound": "11:05 AM on Wed, Feb 5",
"arrival_time_ahead_outbound": "",
"duration_outbound": "2 hr 15 min",
"stops_outbound": 0,
"name_return": "Ryanair",
"departure_return": "9:50 AM on Wed, Feb 5",
"arrival_return": "11:05 AM on Wed, Feb 5",
"arrival_time_ahead_return": "",
"duration_return": "2 hr 15 min",
"stops_return": 0,
"delay": null,
"price": "$48",
"departure_airport": "BVA",
"arrival_airport": "OPO"
},
{
"is_best": true,
"name_outbound": "Ryanair",
"departure_outbound": "9:45 PM on Wed, Feb 5",
"arrival_outbound": "11:00 PM on Wed, Feb 5",
"arrival_time_ahead_outbound": "",
"duration_outbound": "2 hr 15 min",
"stops_outbound": 0,
"name_return": "Ryanair",
"departure_return": "9:45 PM on Wed, Feb 5",
"arrival_return": "11:00 PM on Wed, Feb 5",
"arrival_time_ahead_return": "",
"duration_return": "2 hr 15 min",
"stops_return": 0,
"delay": null,
"price": "$61",
"departure_airport": "BVA",
"arrival_airport": "OPO"
},
{
"is_best": true,
"name_outbound": "Self transferThis trip includes tickets from multiple airlines. Missed connections may be protected by the booking provider.",
"departure_outbound": "9:15 AM on Wed, Feb 5",
"arrival_outbound": "8:50 AM on Thu, Feb 6",
"arrival_time_ahead_outbound": "+1",
"duration_outbound": "24 hr 35 min",
"stops_outbound": 2,
"name_return": "Self transferThis trip includes tickets from multiple airlines. Missed connections may be protected by the booking provider.",
"departure_return": "9:15 AM on Wed, Feb 5",
"arrival_return": "8:50 AM on Thu, Feb 6",
"arrival_time_ahead_return": "+1",
"duration_return": "24 hr 35 min",
"stops_return": 2,
"delay": null,
"price": "$200",
"departure_airport": "BVA",
"arrival_airport": "OPO"
},
TL;DR: Maybe I'm missing something, but to me there should be a way to access the outbound flight data and the return flight data