Commit 307aba44 authored by Volker Krause's avatar Volker Krause
Browse files

Add Airdo confirmation mail extractor script

parent ac3816d3
Pipeline #78099 skipped
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseConfirmation(text, node) {
var flightRes = new Array();
var idx = 0;
while (true) {
const flight = text.substr(idx).match(/\[\d+\]\n(\d{1,2} \w+)\(.*\) ([A-Z0-9]+) (\d+)\n(.*) - (.*)\n.*?(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/);
if (!flight) {
break;
}
idx += flight.index + flight[0].length;
var f = JsonLd.newFlightReservation();
f.reservationFor.departureAirport.name = flight[4];
f.reservationFor.arrivalAirport.name = flight[5];
f.reservationFor.departureTime = JsonLd.toDateTime(flight[1] + flight[6], "d MMMMhh:mm", "en");
f.reservationFor.arrivalTime = JsonLd.toDateTime(flight[1] + flight[7], "d MMMMhh:mm", "en");
f.reservationFor.airline.iataCode = flight[2];
f.reservationFor.flightNumber = flight[3];
flightRes.push(f);
}
const seats = text.match(/\[Seat Number\]([\s\S]+?)\n\[/);
if (!seats) {
return flightRes;
}
var reservations = new Array();
for (seat of seats[1].split(/\n/)) {
const passenger = seat.match(/(.*) (\d+[A-Z])[\n\[]/);
if (!passenger) {
continue;
}
for (flight of flightRes) {
var res = JsonLd.clone(flight);
res.underName.name = passenger[1];
res.airplaneSeat = passenger[2];
reservations.push(res);
}
}
return reservations;
}
{
"filter": [
{
"field": "From",
"match": "@airdo.co.jp",
"mimeType": "message/rfc822",
"scope": "Parent"
}
],
"function": "parseConfirmation",
"mimeType": "text/plain",
"script": "airdo.js"
}
......@@ -16,6 +16,8 @@
<file>airbaltic.js</file>
<file>aircoach-ie.json</file>
<file>aircoach-ie.js</file>
<file>airdo.json</file>
<file>airdo.js</file>
<file>amadeus.json</file>
<file>amadeus.js</file>
<file>americanairlines.json</file>
......
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