Skip to content
GitLab
Menu
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
8ccca367
Commit
8ccca367
authored
Jul 11, 2021
by
Volker Krause
Browse files
Add sro.nl ticket extractor
parent
af31a346
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/scripts/extractors.qrc
View file @
8ccca367
...
...
@@ -99,6 +99,8 @@
<file>sncb.js</file>
<file>sncf.json</file>
<file>sncf.js</file>
<file>sro-nl.json</file>
<file>sro-nl.js</file>
<file>stansted-express.json</file>
<file>stansted-express.js</file>
<file>stuttgarter-baeder.json</file>
...
...
src/lib/scripts/sro-nl.js
0 → 100644
View file @
8ccca367
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function
parseTicket
(
html
,
node
)
{
var
res
=
JsonLd
.
newEventReservation
();
var
ticketNode
=
html
.
eval
(
'
//img/../../../../..
'
)[
1
];
res
.
reservationFor
.
name
=
ticketNode
.
recursiveContent
.
match
(
/
(
.*
)\n
/
)[
1
];
const
text
=
html
.
root
.
recursiveContent
;
const
dt
=
text
.
match
(
/Geldig op
\s
+
(\d{2}
-
\d{2}
-
\d{4})
+
(\d
+:
\d{2})
*- *
(\d
+:
\d{2})
/
);
res
.
reservationFor
.
startDate
=
JsonLd
.
toDateTime
(
dt
[
1
]
+
dt
[
2
],
"
dd-MM-yyyyhh:mm
"
,
"
nl
"
);
res
.
reservationFor
.
endDate
=
JsonLd
.
toDateTime
(
dt
[
1
]
+
dt
[
3
],
"
dd-MM-yyyyhh:mm
"
,
"
nl
"
);
res
.
reservationNumber
=
text
.
match
(
/nummer
(\d{10})
/
)[
1
];
res
.
underName
.
name
=
text
.
match
(
/naam van
\s
+
(
.+
)\n
/
)[
1
];
const
barcode
=
node
.
findChildNodes
({
mimeType
:
"
text/plain
"
,
match
:
"
[^
\
s]
"
,
scope
:
"
Descendants
"
})[
0
];
res
.
reservedTicket
.
ticketToken
=
'
qrCode:
'
+
barcode
.
content
;
return
res
;
}
src/lib/scripts/sro-nl.json
0 → 100644
View file @
8ccca367
{
"filter"
:
[
{
"field"
:
"From"
,
"match"
:
"@sro.nl"
,
"mimeType"
:
"message/rfc822"
,
"scope"
:
"Parent"
}
],
"function"
:
"parseTicket"
,
"mimeType"
:
"text/html"
,
"script"
:
"sro-nl.js"
}
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