Commit 8ccca367 authored by Volker Krause's avatar Volker Krause
Browse files

Add sro.nl ticket extractor

parent af31a346
......@@ -99,6 +99,8 @@
<file>sncb.js</file>
<file>sncf.json</file>
<file>sncf.js</file>
<file>sro-nl.json</file>
<file>sro-nl.js</file>
<file>stansted-express.json</file>
<file>stansted-express.js</file>
<file>stuttgarter-baeder.json</file>
......
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseTicket(html, node) {
var res = JsonLd.newEventReservation();
var ticketNode = html.eval('//img/../../../../..')[1];
res.reservationFor.name = ticketNode.recursiveContent.match(/(.*)\n/)[1];
const text = html.root.recursiveContent;
const dt = text.match(/Geldig op\s+(\d{2}-\d{2}-\d{4}) +(\d+:\d{2}) *- *(\d+:\d{2})/);
res.reservationFor.startDate = JsonLd.toDateTime(dt[1] + dt[2], "dd-MM-yyyyhh:mm", "nl");
res.reservationFor.endDate = JsonLd.toDateTime(dt[1] + dt[3], "dd-MM-yyyyhh:mm", "nl");
res.reservationNumber = text.match(/nummer (\d{10}) /)[1];
res.underName.name = text.match(/naam van\s+(.+)\n/)[1];
const barcode = node.findChildNodes({ mimeType: "text/plain", match: "[^\s]", scope: "Descendants" })[0];
res.reservedTicket.ticketToken = 'qrCode:' + barcode.content;
return res;
}
{
"filter": [
{
"field": "From",
"match": "@sro.nl",
"mimeType": "message/rfc822",
"scope": "Parent"
}
],
"function": "parseTicket",
"mimeType": "text/html",
"script": "sro-nl.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