Commit cff357a7 authored by Volker Krause's avatar Volker Krause
Browse files

Add Bateliers Arcachon extractor script

parent ac9e7f94
Pipeline #269545 passed with stage
in 11 minutes and 21 seconds
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parsePdf(pdf) {
const text = pdf.text;
let idx = 0;
let reservations = [];
while (true) {
const trip = text.substr(idx).match(/Billet n° \d+ \/ \d+\n.*\n *(.*?) +(.*?) +(.*?) +(.*)\n *(\d{2}\/\d{2}\/\d{4}) +(\d{2}\/\d{2}\/\d{4})\n *(\d{2}:\d{2}) +(\d{2}:\d{2}) +(\d{2}:\d{2}) +(\d{2}:\d{2})\n +billet n° (\d+)\n/);
if (!trip) {
break;
}
let out = JsonLd.newBoatReservation();
out.reservationFor.departureBoatTerminal.name = trip[1];
out.reservationFor.arrivalBoatTerminal.name = trip[2];
out.reservationFor.departureTime = JsonLd.toDateTime(trip[5] + trip[7], 'dd/MM/yyyyhh:mm', 'fr');
out.reservationFor.arrivalTime = JsonLd.toDateTime(trip[5] + trip[8], 'dd/MM/yyyyhh:mm', 'fr');
out.reservationNumber = trip[11];
out.reservedTicket.ticketToken = 'barcode128:' + trip[11];
reservations.push(out);
let ret = JsonLd.newBoatReservation();
ret.reservationFor.departureBoatTerminal.name = trip[3];
ret.reservationFor.arrivalBoatTerminal.name = trip[4];
ret.reservationFor.departureTime = JsonLd.toDateTime(trip[6] + trip[9], 'dd/MM/yyyyhh:mm', 'fr');
ret.reservationFor.arrivalTime = JsonLd.toDateTime(trip[6] + trip[10], 'dd/MM/yyyyhh:mm', 'fr');
ret.reservationNumber = trip[11];
ret.reservedTicket.ticketToken = 'barcode128:' + trip[11];
reservations.push(ret);
idx += trip.index + trip[0].length;
}
return reservations;
}
{
"filter": [
{
"field": "title",
"match": "^Confirmation de votre réservation \\d+$",
"mimeType": "application/pdf",
"scope": "Current"
}
],
"function": "parsePdf",
"mimeType": "application/pdf",
"script": "bateliers-arcachon.js"
}
......@@ -30,6 +30,8 @@
<file>availpro.js</file>
<file>baeder-suite.json</file>
<file>baeder-suite.js</file>
<file>bateliers-arcachon.json</file>
<file>bateliers-arcachon.js</file>
<file>blablacar-bus.json</file>
<file>blablacar-bus.js</file>
<file>booking.json</file>
......
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