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
9e6522a9
Commit
9e6522a9
authored
Oct 09, 2022
by
Volker Krause
Browse files
Add extractor script for Ouigo Spain PDF tickets
This fills in the gaps of what we cannot get from their barcode.
parent
f49bfa8f
Pipeline
#244545
passed with stage
in 2 minutes and 57 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/scripts/ouigo-es.js
View file @
9e6522a9
...
...
@@ -27,3 +27,19 @@ function parseBarcode(content) {
res
.
reservedTicket
.
ticketedSeat
.
seatNumber
=
content
.
substr
(
55
,
3
);
return
res
;
}
function
parsePdf
(
pdf
,
node
,
triggerNode
)
{
const
page
=
pdf
.
pages
[
triggerNode
.
location
];
let
res
=
triggerNode
.
result
[
0
];
const
topLeft
=
page
.
textInRect
(
0.0
,
0.0
,
0.5
,
0.5
);
const
stations
=
topLeft
.
match
(
/
\n(
.*
)\n\d\d
:
\d\d\n(
.*
)\n(\d\d
:
\d\d)
/
);
res
.
reservationFor
.
departureStation
.
name
=
stations
[
1
];
res
.
reservationFor
.
arrivalStation
.
name
=
stations
[
2
];
res
.
reservationFor
.
arrivalTime
=
JsonLd
.
toDateTime
(
stations
[
3
],
"
hh:mm
"
,
"
es
"
);
const
topRight
=
page
.
textInRect
(
0.5
,
0.0
,
1.0
,
0.5
);
res
.
underName
.
name
=
topRight
.
match
(
/^
(
.*
)\n
/
)[
1
];
res
.
reservationNumber
=
topRight
.
match
(
/ +
([
A-Z0-9
]{6})\n
/
)[
1
];
return
res
;
}
src/lib/scripts/ouigo-es.json
View file @
9e6522a9
{
[
{
"filter"
:
[
{
"match"
:
"^
\\
d{25}
\\
/
\\
d{2}
\\
/
\\
d{6}:
\\
d{16}"
,
...
...
@@ -9,4 +9,16 @@
"function"
:
"parseBarcode"
,
"mimeType"
:
"text/plain"
,
"script"
:
"ouigo-es.js"
}
},
{
"filter"
:
[
{
"match"
:
"^
\\
d{25}
\\
/
\\
d{2}
\\
/
\\
d{6}:
\\
d{16}"
,
"mimeType"
:
"text/plain"
,
"scope"
:
"Descendants"
}
],
"function"
:
"parsePdf"
,
"mimeType"
:
"application/pdf"
,
"script"
:
"ouigo-es.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