Commit d7f54cf1 authored by Volker Krause's avatar Volker Krause
Browse files

Port more extractor scripts away from the old Context API

Also, change filter expressions to look for IATA BCBP data directly,
rather than their extractor results.
parent 1f5eddff
Pipeline #62694 passed with stages
in 12 minutes and 23 seconds
......@@ -4,10 +4,10 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function main(pdf)
function main(pdf, node, triggerNode)
{
var res = Context.data[0];
var page = pdf.pages[Context.pdfPageNumber];
var res = triggerNode.result[0];
var page = pdf.pages[triggerNode.location];
var time = page.text.match(/Boarding\s+(\d{1,2}.\d{1,2}.\d{4})[\s.]+?(\d{2}:\d{2})/);
if (time) {
res.reservationFor.boardingTime = JsonLd.toDateTime(time[1] + time[2], "dd.MM.yyyyhh:mm", "en")
......
......@@ -2,7 +2,7 @@
"mimeType": "application/pdf",
"filter": [
{ "field": "From", "match": "@airbaltic.com", "mimeType": "message/rfc822", "scope": "Ancestors" },
{ "field": "reservationFor.airline.iataCode", "match": "BT", "mimeType": "application/ld+json", "scope": "Descendants" }
{ "field": "operatingCarrierDesignator", "match": "BT", "mimeType": "internal/iata-bcbp", "scope": "Descendants" }
],
"script": "airbaltic.js"
}
......@@ -2,7 +2,7 @@
"mimeType": "application/pdf",
"filter": [
{ "field": "From", "match": "americanairlines@aa.com", "mimeType": "message/rfc822", "scope": "Ancestors" },
{ "field": "reservationFor.airline.iataCode", "match": "AA", "mimeType": "application/ld+json", "scope": "Descendants" }
{ "field": "operatingCarrierDesignator", "match": "AA", "mimeType": "internal/iata-bcbp", "scope": "Descendants" }
],
"script": "americanairlines.js"
}
......@@ -10,7 +10,7 @@
"mimeType": "application/pdf",
"filter": [
{ "field": "From", "match": "brusselsairlines.com", "mimeType": "message/rfc822", "scope": "Ancestors" },
{ "field": "reservationFor.airline.iataCode", "match": "SN", "mimeType": "application/ld+json", "scope": "Descendants" }
{ "field": "operatingCarrierDesignator", "match": "SN", "mimeType": "internal/iata-bcbp", "scope": "Descendants" }
],
"script": "brusselsairlines-receipt.js"
}
......
......@@ -66,11 +66,11 @@ function parseHtmlBooking(doc) {
return reservations;
}
function parsePdfBoardingPass(pdf)
function parsePdfBoardingPass(pdf, node, triggerNode)
{
var res = Context.data[0];
var res = triggerNode.result[0];
var page = pdf.pages[Context.pdfPageNumber];
var page = pdf.pages[triggerNode.location];
var rightCol = page.textInRect(0.65, 0, 1, 0.25);
var depName = rightCol.match(/(?:from|Flying)\n\([A-Z]{3}\) ([^]*?)\n(?:to|Going)/);
if (depName)
......
......@@ -8,9 +8,9 @@
{
"mimeType": "application/pdf",
"filter": [
{ "field": "reservationFor.airline.iataCode", "match": "EJU", "mimeType": "application/ld+json", "scope": "Descendants" },
{ "field": "reservationFor.airline.iataCode", "match": "EZS", "mimeType": "application/ld+json", "scope": "Descendants" },
{ "field": "reservationFor.airline.iataCode", "match": "EZY", "mimeType": "application/ld+json", "scope": "Descendants" }
{ "field": "operatingCarrierDesignator", "match": "EJU", "mimeType": "internal/iata-bcbp", "scope": "Descendants" },
{ "field": "operatingCarrierDesignator", "match": "EZS", "mimeType": "internal/iata-bcbp", "scope": "Descendants" },
{ "field": "operatingCarrierDesignator", "match": "EZY", "mimeType": "internal/iata-bcbp", "scope": "Descendants" }
],
"script": "easyjet.js",
"function": "parsePdfBoardingPass"
......
......@@ -4,9 +4,9 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function main(pdf) {
var res = Context.data[0];
var page = pdf.pages[Context.pdfPageNumber];
function main(pdf, node, triggerNode) {
var res = triggerNode.result[0];
var page = pdf.pages[triggerNode.location];
// needs to be done manually as we don't have PDF ctime for this to work automatically
var date = page.text.match(/Date +(\d\d \w{3} \d\d)/);
......
......@@ -3,8 +3,8 @@
"filter": [
{
"match": "6E",
"field": "reservationFor.airline.iataCode",
"mimeType": "application/ld+json",
"field": "operatingCarrierDesignator",
"mimeType": "internal/iata-bcbp",
"scope": "Descendants"
}
],
......
......@@ -7,9 +7,9 @@
"scope": "Ancestors"
},
{
"field": "reservationFor.airline.iataCode",
"field": "operatingCarrierDesignator",
"match": "D[8Y]",
"mimeType": "application/ld+json",
"mimeType": "internal/iata-bcbp",
"scope": "Descendants"
}
],
......
......@@ -3,7 +3,7 @@
"mimeType": "application/pdf",
"filter": [
{ "field": "From", "match": "no-reply@flysas.com", "mimeType": "message/rfc822", "scope": "Ancestors" },
{ "field": "reservationFor.airline.iataCode", "match": "SK", "mimeType": "application/ld+json", "scope": "Descendants" }
{ "field": "operatingCarrierDesignator", "match": "SK", "mimeType": "internal/iata-bcbp", "scope": "Descendants" }
],
"script": "sas-boardingpass.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