Commit 2e5f734d authored by Volker Krause's avatar Volker Krause
Browse files

Add basic extractor script for Peach Aviation

No samples for multi-leg or multi-passenger scenarios yet though.
parent d18dae5e
Pipeline #158819 passed with stages
in 1 minute and 47 seconds
......@@ -102,6 +102,8 @@
<file>oebb.js</file>
<file>onepagebooking.json</file>
<file>onepagebooking.js</file>
<file>peach-aviation.json</file>
<file>peach-aviation.js</file>
<file>pretix.json</file>
<file>pretix.js</file>
<file>regiojet.json</file>
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseReservation(content) {
const ref = content.match(/Booking Reference\n(\S{6})/)[1];
// TODO multiple legs?
const leg = content.match(/(\S{2}\d{1,4})[\s\S]*?(.*) (.*)\n(\d{4}\/\d{2}\/\d{2}).*(\d{2}:\d{2})\n| ↓\n(.*) (.*)\n(\d{4}\/\d{2}\/\d{2}).*(\d{2}:\d{2})/);
var res = JsonLd.newFlightReservation();
res.reservationNumber = ref;
res.reservationFor.flightNumber = leg[1];
res.reservationFor.departureAirport.name = leg[2];
res.reservationFor.departureTerminal = leg[3];
res.reservationFor.departureTime = JsonLd.toDateTime(leg[4] + ' ' + leg[5], 'yyyy/MM/dd hh:mm', 'jp');
res.reservationFor.arrivalAirport.name = leg[6];
res.reservationFor.arrivalTerminal = leg[7];
res.reservationFor.arrivalTime = JsonLd.toDateTime(leg[8] + ' ' + leg[9], 'yyyy/MM/dd hh:mm', 'jp');
// TODO multiple passengers?
const pas = content.match(/Name: (.*)\nTitle: .*\n\S{2}\d{1,4}\n├ Advance Seat selection: (.*)\n/);
res.underName.name = pas[1];
res.airplaneSeat = pas[2];
return res;
}
{
"filter": [
{
"field": "From",
"match": "@resmail.flypeach.com",
"mimeType": "message/rfc822",
"scope": "Ancestors"
}
],
"function": "parseReservation",
"mimeType": "text/plain",
"script": "peach-aviation.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