From 257ad67a1d2b70bf2699db6e4fda4d4c21e8946f Mon Sep 17 00:00:00 2001 From: Ray Berger Date: Tue, 1 Jun 2021 17:11:29 -1000 Subject: [PATCH] add segments --- southwest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/southwest.py b/southwest.py index c958a3e..b66b0e3 100644 --- a/southwest.py +++ b/southwest.py @@ -84,11 +84,12 @@ def page_parse(data): option['flight_num'] = "/".join(flight["flightNumbers"]) option['depart_date'] = date_pattern.match(flight['departureDateTime']).group(1) option['route'] = [flight['originationAirportCode']] - for stop in flight['stopsDetails']: - option['route'].append(stop['destinationAirportCode']) + for segment in flight['segments']: + for stop in segment['stopsDetails']: + option['route'].append(stop['destinationAirportCode']) option['depart_time'] = date_pattern.match(flight['departureDateTime']).group(2) option['arrive_time'] = date_pattern.match(flight['arrivalDateTime']).group(2) - option['num_stops'] = len(flight['stopsDetails']) - 1 + option['num_stops'] = len(flight['segments']) - 1 hours = flight['totalDuration'] / 60 minutes = flight['totalDuration'] % 60 option['duration'] = "%02i:%02i" % (hours, minutes)