Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
7b3ace7c
Commit
7b3ace7c
authored
Mar 05, 2022
by
Volker Krause
Browse files
Add extractor for Spring Airlines bookings
parent
972da43b
Pipeline
#145361
passed with stages
in 4 minutes and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/scripts/extractors.qrc
View file @
7b3ace7c
...
...
@@ -125,6 +125,8 @@
<file>sncf.js</file>
<file>sro-nl.json</file>
<file>sro-nl.js</file>
<file>springairlines.json</file>
<file>springairlines.js</file>
<file>stansted-express.json</file>
<file>stansted-express.js</file>
<file>swiss.json</file>
...
...
src/lib/scripts/springairlines.js
0 → 100644
View file @
7b3ace7c
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function
parseConfirmation
(
content
)
{
var
reservations
=
[];
const
text
=
content
.
pages
[
0
].
text
;
const
ref
=
text
.
match
(
/Reference.
\s
*
([
A-Z0-9
]{6})
/
)[
1
];
var
idx
=
0
;
while
(
true
)
{
const
leg
=
text
.
substr
(
idx
).
match
(
/Flight Time
\n\s
*
(\d\d
:
\d\d)\s
*
(\d\d
:
\d\d)\n\s
*
(\d\d\d\d\/\d\d\/\d\d)\s
*
\(
.*
\)\s
+
([
A-Z0-9
]{2}\d{1,4})
.*
\n\s
*
(
.*
?)\s\s
+
(
.*
)
/
);
if
(
!
leg
)
{
break
;
}
idx
+=
leg
.
index
+
leg
[
0
].
length
;
var
flight
=
JsonLd
.
newFlightReservation
();
flight
.
reservationNumber
=
ref
;
flight
.
reservationFor
.
departureAirport
.
name
=
leg
[
5
];
flight
.
reservationFor
.
departureTime
=
JsonLd
.
toDateTime
(
leg
[
3
]
+
leg
[
1
],
"
yyyy/MM/ddhh:mm
"
,
"
jp
"
);
flight
.
reservationFor
.
arrivalAirport
.
name
=
leg
[
6
];
flight
.
reservationFor
.
arrivalTime
=
JsonLd
.
toDateTime
(
leg
[
3
]
+
leg
[
2
],
"
yyyy/MM/ddhh:mm
"
,
"
jp
"
);
flight
.
reservationFor
.
flightNumber
=
leg
[
4
];
// TODO handle multiple passengers, once we have a sample for that
const
pas
=
text
.
substr
(
idx
).
match
(
/
\s
*
(
.*
)\/(
.*
?)
+.*
(\d{1,2}[
A-K
])
.*
\n
/
);
idx
+=
leg
.
index
+
leg
[
0
].
length
;
flight
.
underName
.
familyName
=
pas
[
1
];
flight
.
underName
.
givenName
=
pas
[
2
];
flight
.
airplaneSeat
=
pas
[
3
];
reservations
.
push
(
flight
);
}
return
reservations
;
}
src/lib/scripts/springairlines.json
0 → 100644
View file @
7b3ace7c
{
"filter"
:
[
{
"field"
:
"From"
,
"match"
:
"spring@info.springairlines.com"
,
"mimeType"
:
"message/rfc822"
,
"scope"
:
"Ancestors"
}
],
"function"
:
"parseConfirmation"
,
"mimeType"
:
"application/pdf"
,
"script"
:
"springairlines.js"
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment