Commit 9e6522a9 authored by Volker Krause's avatar Volker Krause
Browse files

Add extractor script for Ouigo Spain PDF tickets

This fills in the gaps of what we cannot get from their barcode.
parent f49bfa8f
Pipeline #244545 passed with stage
in 2 minutes and 57 seconds
......@@ -27,3 +27,19 @@ function parseBarcode(content) {
res.reservedTicket.ticketedSeat.seatNumber = content.substr(55, 3);
return res;
}
function parsePdf(pdf, node, triggerNode) {
const page = pdf.pages[triggerNode.location];
let res = triggerNode.result[0];
const topLeft = page.textInRect(0.0, 0.0, 0.5, 0.5);
const stations = topLeft.match(/\n(.*)\n\d\d:\d\d\n(.*)\n(\d\d:\d\d)/);
res.reservationFor.departureStation.name = stations[1];
res.reservationFor.arrivalStation.name = stations[2];
res.reservationFor.arrivalTime = JsonLd.toDateTime(stations[3], "hh:mm", "es");
const topRight = page.textInRect(0.5, 0.0, 1.0, 0.5);
res.underName.name = topRight.match(/^(.*)\n/)[1];
res.reservationNumber = topRight.match(/ +([A-Z0-9]{6})\n/)[1];
return res;
}
{
[{
"filter": [
{
"match": "^\\d{25}\\/\\d{2}\\/\\d{6}:\\d{16}",
......@@ -9,4 +9,16 @@
"function": "parseBarcode",
"mimeType": "text/plain",
"script": "ouigo-es.js"
}
},
{
"filter": [
{
"match": "^\\d{25}\\/\\d{2}\\/\\d{6}:\\d{16}",
"mimeType": "text/plain",
"scope": "Descendants"
}
],
"function": "parsePdf",
"mimeType": "application/pdf",
"script": "ouigo-es.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