Commit 7b3ace7c authored by Volker Krause's avatar Volker Krause
Browse files

Add extractor for Spring Airlines bookings

parent 972da43b
Pipeline #145361 passed with stages
in 4 minutes and 12 seconds
......@@ -125,6 +125,8 @@
<file>sncf.js</file>
<file>sro-nl.json</file>
<file>sro-nl.js</file>
<file>springairlines.json</file>
<file>springairlines.js</file>
<file>stansted-express.json</file>
<file>stansted-express.js</file>
<file>swiss.json</file>
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseConfirmation(content) {
var reservations = [];
const text = content.pages[0].text;
const ref = text.match(/Reference.\s*([A-Z0-9]{6})/)[1];
var idx = 0;
while (true) {
const leg = text.substr(idx).match(/Flight Time\n\s*(\d\d:\d\d)\s*(\d\d:\d\d)\n\s*(\d\d\d\d\/\d\d\/\d\d)\s*\(.*\)\s+([A-Z0-9]{2}\d{1,4}).*\n\s*(.*?)\s\s+(.*)/);
if (!leg) {
break;
}
idx += leg.index + leg[0].length;
var flight = JsonLd.newFlightReservation();
flight.reservationNumber = ref;
flight.reservationFor.departureAirport.name = leg[5];
flight.reservationFor.departureTime = JsonLd.toDateTime(leg[3] + leg[1], "yyyy/MM/ddhh:mm", "jp");
flight.reservationFor.arrivalAirport.name = leg[6];
flight.reservationFor.arrivalTime = JsonLd.toDateTime(leg[3] + leg[2], "yyyy/MM/ddhh:mm", "jp");
flight.reservationFor.flightNumber = leg[4];
// TODO handle multiple passengers, once we have a sample for that
const pas = text.substr(idx).match(/\s*(.*)\/(.*?) +.* (\d{1,2}[A-K]).*\n/);
idx += leg.index + leg[0].length;
flight.underName.familyName = pas[1];
flight.underName.givenName = pas[2];
flight.airplaneSeat = pas[3];
reservations.push(flight);
}
return reservations;
}
{
"filter": [
{
"field": "From",
"match": "spring@info.springairlines.com",
"mimeType": "message/rfc822",
"scope": "Ancestors"
}
],
"function": "parseConfirmation",
"mimeType": "application/pdf",
"script": "springairlines.js"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment