Commit 71b0372b authored by Jan Hambrecht's avatar Jan Hambrecht Committed by Volker Krause
Browse files

Update eurowings plaintext extractor

The eurowings plaintext extractor did not work anymore due to slight
changes in booking confirmation text received from eurowings.
The various regex had to be slightly extended to catch the correct data
points from the text.

(cherry picked from commit 7d86a0ed)
parent b82a65bf
Pipeline #164657 passed with stages
in 1 minute and 43 seconds
......@@ -6,11 +6,11 @@
function main(text) {
var reservations = new Array();
var bookingRef = text.match(/(?:Individual reservation code|Individueller Buchungscode):\s*\*\* ([A-Z0-9]{6})/);
var bookingRef = text.match(/(?:Individual reservation code|Individueller Buchungscode):?\s*(?:\(beim Check-In angeben\))?\s*\*\* ([A-Z0-9]{6})/);
var pos = 0;
while (true) {
var flightLine = text.substr(pos).match(/(?:Flight|Flug): ([0-9]{2}\.[0-9]{2}\.[0-9]{4})\s*\|\s*([A-Z0-9]{2}) ([0-9]{3,4}).*\n/);
var flightLine = text.substr(pos).match(/(?:Flight|Flug): ([0-9]{2}\.[0-9]{2}\.[0-9]{4})\s*\|\s*(?:Flugnummer\:)?\s*([A-Z0-9]{2}) ([0-9]{3,4}).*\n/);
if (!flightLine)
break;
var idx = flightLine.index + flightLine[0].length;
......@@ -21,20 +21,20 @@ function main(text) {
res.reservationFor.airline.iataCode = flightLine[2];
var opByLine = text.substr(pos + idx).match(/^\s*\* (?:operated by|durchgeführt von) (.*)\n/);
var opByLine = text.substr(pos + idx).match(/^\s*\* (?:[Oo]perated by|durchgeführt von) (.*)\n/);
if (opByLine) {
idx += opByLine.index + opByLine[0].length;
res.reservationFor.airline.name = opByLine[1];
}
var depLine = text.substr(pos + idx).match(/(?:Departure|Abflug):\s*([0-9]{2}:[0-9]{2})\s+(.*)\n/);
var depLine = text.substr(pos + idx).match(/(?:Departure|Abflug):?\s*([0-9]{2}:[0-9]{2})\s+(.*)\n/);
if (!depLine)
break;
idx += depLine.index + depLine[0].length;
res.reservationFor.departureTime = JsonLd.toDateTime(flightLine[1] + ' ' + depLine[1], "dd.MM.yyyy hh:mm", "en");
res.reservationFor.departureAirport.name = depLine[2];
var arrLine = text.substr(pos + idx).match(/(?:Arrival|Ankunft):\s*([0-9]{2}:[0-9]{2})\s+(.*)\n/);
var arrLine = text.substr(pos + idx).match(/(?:Arrival|Ankunft):?\s*([0-9]{2}:[0-9]{2})\s+(.*)\n/);
if (!arrLine)
break;
idx += arrLine.index + arrLine[0].length;
......
Supports Markdown
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