Commit 2c040d1e authored by Volker Krause's avatar Volker Krause
Browse files

Add eki-net.com train reservation extractor

parent ca6c4ded
Pipeline #82622 canceled with stage
in 17 seconds
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parseReservation(text)
{
var reservations = new Array();
const resNum = text.match(/予約番号\n(.*)\n/);
const date = text.match(/乗車日.*?(\d.*)\n/);
const trainInfo = text.match(/列車情報==([\s\S]*?)==/)[1];
const legs = trainInfo.split(/\(\d列車目\)\n/);
for (leg of legs) {
console.log(leg);
const fromTo = leg.match(/区 間:(.*?)\((.*?)\)(.*?)\((.*?)\)\n/);
if (!fromTo) {
continue;
}
var res = JsonLd.newTrainReservation();
res.reservationFor.departureStation.name = fromTo[1];
res.reservationFor.departureStation.address.addressCountry = 'JP';
res.reservationFor.departureTime = JsonLd.toDateTime(date[1] + fromTo[2], 'yyyy年MM月dd日hh時mm分', 'jp');
res.reservationFor.arrivalStation.name = fromTo[3];
res.reservationFor.arrivalStation.address.addressCountry = 'JP';
res.reservationFor.arrivalTime = JsonLd.toDateTime(date[1] + fromTo[4], 'yyyy年MM月dd日hh時mm分', 'jp');
const trainName = leg.match(/列車名:(.*)\n/);
res.reservationFor.trainName = trainName[1];
const seat = leg.match(/座 席:(.*号車)(.*)\n/);
if (seat) {
res.reservedTicket.ticketedSeat.seatSection = seat[1];
res.reservedTicket.ticketedSeat.seatNumber = seat[2];
}
res.reservationNumber = resNum[1];
reservations.push(res);
}
return reservations;
}
{
"filter": [
{
"field": "From",
"match": "reservation@eki-net.com",
"mimeType": "message/rfc822",
"scope": "Parent"
}
],
"function": "parseReservation",
"mimeType": "text/plain",
"script": "eki-net.js"
}
......@@ -49,6 +49,8 @@
<file>easyairportparking-pkpass.js</file>
<file>easyjet.json</file>
<file>easyjet.js</file>
<file>eki-net.json</file>
<file>eki-net.js</file>
<file>eurowings.json</file>
<file>eurowings.js</file>
<file>eurowings-pkpass.js</file>
......
Markdown is supported
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