Commit 1899f74e authored by Volker Krause's avatar Volker Krause
Browse files

Add Fjord Line extractor script

parent 6093e5c4
Pipeline #211994 passed with stage
in 4 minutes and 57 seconds
......@@ -64,6 +64,8 @@
<file>fcmtravel.js</file>
<file>feratel-card.json</file>
<file>feratel-card.js</file>
<file>fjordline.json</file>
<file>fjordline.js</file>
<file>flixbus.json</file>
<file>flixbus.js</file>
<file>gnv.it.json</file>
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseTicket(pdf, node, triggerNode) {
const text = pdf.pages[triggerNode.location].text;
if (!text.match(/Fjord Line/))
return;
console.log(text);
let res = JsonLd.newBoatReservation();
const trip = text.match(/(\d{2}.\d{2}.\d{4}) +(.*?) +(\d{2}\.\d{2}) +(.*) +(\d{2}\.\d{2}) +(.*?) +(.*)/);
res.reservationFor.departureBoatTerminal.name = trip[2];
res.reservationFor.departureTime = JsonLd.toDateTime(trip[1] + ' ' + trip[3], 'dd.MM.yyyy hh.mm', 'no');
res.reservationFor.arrivalBoatTerminal.name = trip[4];
res.reservationFor.arrivalTime = JsonLd.toDateTime(trip[1] + ' ' + trip[5], 'dd.MM.yyyy hh.mm', 'no');
res.reservationFor.boatName = trip[6];
res.underName.name = trip[7];
res.reservationNumber = triggerNode.content;
res.reservedTicket.ticketToken = 'qrCode:' + triggerNode.content;
return res;
}
{
"filter": [
{
"match": "^\\d{7}$",
"mimeType": "text/plain",
"scope": "Descendants"
}
],
"function": "parseTicket",
"mimeType": "application/pdf",
"script": "fjordline.js"
}
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