Commit 1826a609 authored by Volker Krause's avatar Volker Krause
Browse files

Generalize VGN extractor script to handle EOSU ticket layouts

The same ticketing system is also used by other German local operators,
the script applies to those as well.
parent 419d5019
Pipeline #200215 passed with stage
in 7 minutes and 10 seconds
/*
SPDX-FileCopyrightText: 2019-2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseTicket(ticket, node) {
var res = JsonLd.newTrainReservation();
res.reservedTicket = node.result[0];
res.underName.name = ticket.ticketLayout.text(0, 0, 72, 1);
res.reservedTicket.name = ticket.ticketLayout.text(1, 0, 72, 1);
const valid = ticket.ticketLayout.text(3, 0, 72, 1).match(/([\d\.: ]+)-([\d\.: ]+)/);
res.reservedTicket.validFrom = JsonLd.toDateTime(valid[1], "dd.MM.yyyy hh:mm", "de");
res.reservedTicket.validUntil = JsonLd.toDateTime(valid[2], "dd.MM.yyyy hh:mm", "de");
if (ticket.ticketLayout.size.height <= 6) {
res.reservedTicket.underName = res.underName;
return res.reservedTicket;
}
res.reservationNumber = res.reservedTicket.ticketNumber;
res.reservationFor.provider = res.reservedTicket.issuedBy;
res.reservationFor.departureTime = res.reservedTicket.validFrom;
res.reservationFor.departureStation.name = ticket.ticketLayout.text(7, 0, 72, 1);
res.reservationFor.arrivalStation.name = ticket.ticketLayout.text(8, 0, 72, 1);
return res;
}
......@@ -2,9 +2,9 @@
{
"mimeType": "internal/uic9183",
"filter": [
{ "field": "carrierId", "match": "3415", "mimeType": "internal/uic9183", "scope": "Current" }
{ "field": "ticketLayout.type", "match": "EOSU", "mimeType": "internal/uic9183", "scope": "Current" }
],
"script": "vgn.js",
"script": "eos.js",
"function": "parseTicket"
}
]
......@@ -53,6 +53,8 @@
<file>easyjet.js</file>
<file>eki-net.json</file>
<file>eki-net.js</file>
<file>eos.json</file>
<file>eos.js</file>
<file>eurowings.json</file>
<file>eurowings.js</file>
<file>eurowings-pkpass.js</file>
......@@ -153,8 +155,6 @@
<file>travelport-galileo.js</file>
<file>trenitalia.json</file>
<file>trenitalia.js</file>
<file>vgn.json</file>
<file>vgn.js</file>
<file>viarail.json</file>
<file>viarail.js</file>
<file>vitolus.json</file>
......
/*
SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseTicket(ticket) {
var res = JsonLd.newTrainReservation();
res.reservationNumber = ticket.pnr;
res.reservedTicket.ticketToken = "aztectBin:" + ByteArray.toBase64(ticket.rawData);
res.underName.name = ticket.ticketLayout.text(0, 0, 72, 1);
res.reservationFor.departureTime = JsonLd.toDateTime(ticket.ticketLayout.text(3, 0, 72, 1).match(/([\d\.: ]+)/)[1], "dd.MM.yyyy hh:mm", "de");
res.reservationFor.departureStation.name = ticket.ticketLayout.text(7, 0, 72, 1);
res.reservationFor.arrivalStation.name = ticket.ticketLayout.text(8, 0, 72, 1);
return res;
}
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