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

Fixes for vitolus extractor

For some reason a newer sample has 18.15 instead of 18:15 in the time
section.

Also with the newer sample the cancellation url isn't matched. I can't
be bothered to properly fix it right now, so at least not fail in that
case.
parent 4e064b94
Pipeline #116168 passed with stage
in 2 minutes and 36 seconds
......@@ -11,7 +11,8 @@ function main(content) {
var theDate = content.match(/Termin Datum: (.*)/)[1]
var theTime = content.match(/Termin Uhrzeit: (.*) Uhr/)[1]
var addr = content.match(/Adresse der Teststation: (.*), (.*), ([0-9]*) (.*)/)
var cancelUrl = content.match(/Für Absagen verwenden Sie bitte folgenden Link: (.*)/)[1]
var cancelUrlMatch = content.match(/Für Absagen verwenden Sie bitte folgenden Link: (.*)/)
const address = JsonLd.newObject("PostalAddress")
address.addressCountry = "DE"
......@@ -21,13 +22,23 @@ function main(content) {
res.reservationFor.name = name
res.potentialAction = JsonLd.newObject("CancelAction")
res.potentialAction.url = cancelUrl
// FIXME some cancel urls are not matched
if (cancelUrlMatch) {
res.potentialAction = JsonLd.newObject("CancelAction")
res.potentialAction.url = cancelUrlMatch[1]
}
res.reservationFor.location.address = address
res.reservationFor.location.name = addr[1]
res.reservationFor.startDate = JsonLd.toDateTime(theDate + " " + theTime, "dd.MM.yyyy hh:mm", "de")
// Both hh::mm and hh.mm are observed in the wild
var dateTime = JsonLd.toDateTime(theDate + " " + theTime, "dd.MM.yyyy hh:mm", "de")
if (isNaN(dateTime.getTime())) {
dateTime = JsonLd.toDateTime(theDate + " " + theTime, "dd.MM.yyyy hh.mm", "de")
}
res.reservationFor.startDate = dateTime
return res
}
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