Commit 3c970ee7 authored by Volker Krause's avatar Volker Krause
Browse files

Add GWR ical extractor script

parent 15a7f62a
......@@ -66,6 +66,8 @@
<file>flixbus.js</file>
<file>gomus.json</file>
<file>gomus.js</file>
<file>gwr.json</file>
<file>gwr.js</file>
<file>hertz.js</file>
<file>hertz.json</file>
<file>hotels.com.json</file>
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseEvent(event) {
let res = JsonLd.newTrainReservation();
res.reservationFor.departureTime = JsonLd.readQDateTime(event, 'dtStart');
res.reservationFor.arrivalTime = JsonLd.readQDateTime(event, 'dtEnd');
const trip = event.description.match(/Journey Details: (.*) \(([A-Z]{3})\) to (.*) \(([A-Z]{3})\)/);
res.reservationFor.departureStation.name = trip[1];
res.reservationFor.departureStation.identifier = 'uk:' + trip[2];
res.reservationFor.arrivalStation.name = trip[3];
res.reservationFor.arrivalStation.identifier = 'uk:' + trip[4];
res.reservationNumber = event.description.match(/Booking Reference: (.*)\n/)[1];
return res;
}
{
"filter": [
{
"field": "uid",
"match": "@tickets.gwr.com$",
"mimeType": "internal/event",
"scope": "Current"
}
],
"function": "parseEvent",
"mimeType": "internal/event",
"script": "gwr.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