Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
KItinerary
Commits
1fc65e9c
Commit
1fc65e9c
authored
Sep 20, 2020
by
Nicolas Fella
Committed by
Volker Krause
Sep 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add extractor for Tierpark Berlin
A somewhat structured PDF with a QR code
parent
c1a9aa4b
Pipeline
#34886
passed with stage
in 13 minutes and 18 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
src/extractors/extractors.qrc
src/extractors/extractors.qrc
+2
-0
src/extractors/tierparkberlin.js
src/extractors/tierparkberlin.js
+60
-0
src/extractors/tierparkberlin.json
src/extractors/tierparkberlin.json
+12
-0
No files found.
src/extractors/extractors.qrc
View file @
1fc65e9c
...
...
@@ -91,6 +91,8 @@
<file>swiss.js</file>
<file>thalys.json</file>
<file>thalys.js</file>
<file>tierparkberlin.json</file>
<file>tierparkberlin.js</file>
<file>travelport-galileo.json</file>
<file>travelport-galileo.js</file>
<file>trenitalia.json</file>
...
...
src/extractors/tierparkberlin.js
0 → 100644
View file @
1fc65e9c
/*
SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function
main
(
input
)
{
var
page
=
input
.
pages
[
Context
.
pdfPageNumber
];
const
lines
=
page
.
text
.
split
(
"
\n
"
)
const
res
=
JsonLd
.
newEventReservation
()
res
.
underName
=
JsonLd
.
newObject
(
"
Person
"
);
let
date
=
""
let
startTime
=
""
let
endTime
=
""
res
.
reservedTicket
.
ticketToken
=
"
qrCode:
"
+
Context
.
barcode
const
address
=
JsonLd
.
newObject
(
"
PostalAddress
"
)
address
.
addressCountry
=
"
DE
"
address
.
addressLocality
=
"
Berlin
"
address
.
addressRegion
=
"
Berlin
"
address
.
postalCode
=
"
10319
"
address
.
streetAddress
=
"
Am Tierpark 125
"
res
.
reservationFor
.
location
.
address
=
address
res
.
reservationFor
.
name
=
"
Tierpark Berlin
"
for
(
line
of
lines
)
{
const
nameMatch
=
line
.
match
(
/Name:
[
]
*
([^\s]
.*
)
/
)
if
(
nameMatch
)
{
res
.
underName
.
name
=
nameMatch
[
1
]
}
const
bookingCodeMatch
=
line
.
match
(
/Booking code:
[
]
*
([^\s]
.*
)
/
)
if
(
bookingCodeMatch
)
{
res
.
reservationNumber
=
bookingCodeMatch
[
1
]
}
const
dateMatch
=
line
.
match
(
/Valid on:
[
]
*
([
0-9
]{1,2}
[
a-zA-Z
]
+
[
0-9
]{4})
/
)
if
(
dateMatch
)
{
date
=
dateMatch
[
1
]
}
const
timeMatch
=
line
.
match
(
/Time slot:
[
]
*
([
0-9
]{1,2}
:
[
0-9
]{1,2}
(
AM|PM
))
-
([
0-9
]{1,2}
:
[
0-9
]{1,2}
(
AM|PM
))
/
)
if
(
timeMatch
)
{
startTime
=
timeMatch
[
1
]
endTime
=
timeMatch
[
3
]
}
}
res
.
reservationFor
.
startDate
=
JsonLd
.
toDateTime
(
date
+
"
"
+
startTime
,
"
dd MMM yyyy h:mm ap
"
,
"
en
"
)
res
.
reservationFor
.
endDate
=
JsonLd
.
toDateTime
(
date
+
"
"
+
endTime
,
"
dd MMM yyyy h:mm ap
"
,
"
en
"
)
return
[
res
]
}
src/extractors/tierparkberlin.json
0 → 100644
View file @
1fc65e9c
{
"filter"
:
[
{
"header"
:
"From"
,
"match"
:
"@tierpark-berlin.de"
,
"type"
:
"Email"
}
],
"function"
:
"main"
,
"script"
:
"tierparkberlin.js"
,
"type"
:
"Pdf"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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