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

Add Trenitalia ical extractor script

parent 92d35f4e
Pipeline #195557 passed with stage
in 2 minutes and 33 seconds
......@@ -82,3 +82,20 @@ function parsePdf(pdf) {
return reservations;
}
function parseEvent(event)
{
let res = JsonLd.newTrainReservation();
res.reservationFor.departureTime = JsonLd.readQDateTime(event, 'dtStart');
res.reservationFor.arrivalTime = JsonLd.readQDateTime(event, 'dtEnd');
res.reservationFor.departureStation.name = event.location;
res.reservationFor.arrivalStation.name = event.description.match(event.location + "-(.*?);")[1];
res.reservationFor.trainNumber = event.description.match(/Train: (.*?),/)[1];
res.reservationNumber = event.description.match(/pnr code ([A-Z0-9]{6})\b/)[1];
const seat = event.description.match(/Coach (.*?), Position (.*?)[;\b]/);
if (seat) {
res.reservedTicket.ticketedSeat.seatSection = seat[1];
res.reservedTicket.ticketedSeat.seatNumber = seat[2];
}
return res;
}
......@@ -6,5 +6,13 @@
],
"script": "trenitalia.js",
"function": "parsePdf"
},
{
"mimeType": "internal/event",
"filter": [
{ "mimeType": "internal/event", "field": "organizer.email", "match": "webmaster@trenitalia.it", "scope": "Current" }
],
"script": "trenitalia.js",
"function": "parseEvent"
}
]
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