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

Basic extractor for simplebooking.it confirmation emails

That's the system used by the recommended Akademy 2019 accommodation.
parent 8bbf97b7
......@@ -51,6 +51,8 @@
<file>sas.json</file>
<file>sas-boardingpass.js</file>
<file>sas-receipt.js</file>
<file>simplebooking.json</file>
<file>simplebooking.js</file>
<file>sncf.json</file>
<file>sncf.js</file>
<file>stansted-express.json</file>
......
/*
Copyright (c) 2019 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
function parseHtml(doc)
{
var text = doc.root.recursiveContent;
var res = JsonLd.newLodgingReservation();
res.reservationNumber = text.match(/Booking #:\s*(.*?)\n/)[1];
res.reservationFor.name = doc.eval("//h1")[0].content;
res.checkinTime = JsonLd.toDateTime(text.match(/Arrival:\s*(.*?)\n/)[1], "dd MMM yyyy", "en");
res.checkoutTime = JsonLd.toDateTime(text.match(/Departure:\s*(.*?)\n/)[1], "dd MMM yyyy", "en");
res.reservationFor.geo.latitude = text.match(/Latitude:\s(-?\d+.\d+)/)[1] * 1.0;
res.reservationFor.geo.longitude = text.match(/Longitude:\s(-?\d+.\d+)/)[1] * 1.0;
console.log(text);
var addr = text.match(/Lodging information[\n\s]+(.*?)\n[\n\s]+(.*?)\n[\n\s]+(.*?)\n[\n\s]+Telephone: (.*?)\n.*\n*\s+Email:\s+(.*?)\n\s+Internet:\s+(.*?)\n/);
res.reservationFor.address.streetAddress = addr[2];
res.reservationFor.address.addressLocality = addr[3];
res.reservationFor.telephone = addr[4];
res.reservationFor.email = addr[5];
res.reservationFor.url = addr[6];
return res;
}
[
{
"type": "html",
"filter": [ { "header": "From", "match": "@simplebooking.it" } ],
"script": "simplebooking.js",
"function": "parseHtml"
}
]
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