Commit c69d34ab authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Add terminland extractor

Terminland is sending emails for covid test appointments
parent 15906f39
Pipeline #67061 canceled with stages
......@@ -103,6 +103,8 @@
<file>stansted-express.js</file>
<file>swiss.json</file>
<file>swiss.js</file>
<file>terminland-de.json</file>
<file>terminland-de.js</file>
<file>thalys.json</file>
<file>thalys.js</file>
<file>tierparkberlin.json</file>
......
/*
SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function main(doc) {
var res = JsonLd.newEventReservation();
const dateString = doc.eval("//div/div/span")[0].content.replace("\n", " ").match(".*, (.*) Uhr")[1]
const addressBlock = doc.eval("//div/div")[2].content.split("\n")
const placeName = addressBlock[2]
const street = addressBlock[4]
const zipAndCity = addressBlock[5]
const zip = zipAndCity.match(/([0-9]*)/)[1]
const city = zipAndCity.match(/[0-9]* (.*)/)[1]
const firstName = doc.eval("//div/div/table/tr/td")[2].content
const lastName = doc.eval("//div/div/table/tr/td")[5].content
const cancelUrl = doc.eval("//div/div/div/a")[1].content
const address = JsonLd.newObject("PostalAddress")
address.addressCountry = "DE"
address.addressLocality = city
address.postalCode = zip
address.streetAddress = street
res.reservationFor.location.address = address
res.reservationFor.location.name = placeName
res.reservationFor.startDate = JsonLd.toDateTime(dateString, "dd.MM.yyyy hh:mm", "de")
res.reservationFor.name = firstName + " " + lastName
res.potentialAction = JsonLd.newObject("CancelAction")
res.potentialAction.url = cancelUrl
return res
}
{
"filter": [
{
"field": "From",
"match": "@terminland.de",
"mimeType": "message/rfc822",
"scope": "Ancestors"
}
],
"function": "main",
"mimeType": "text/html",
"script": "terminland-de.js"
}
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