diff --git a/src/extractors/extractors.qrc b/src/extractors/extractors.qrc index e99edc9..be4a1dc 100644 --- a/src/extractors/extractors.qrc +++ b/src/extractors/extractors.qrc @@ -1,76 +1,78 @@ aerlingus.json aerlingus.js airbaltic.json airbaltic.js aircoach-ie.json aircoach-ie.js amadeus.json amadeus.js americanairlines.json americanairlines.js aohostels.json aohostels.js availpro.json availpro.js booking.json booking.js brusselsairlines.json brusselsairlines.js brusselsairlines-receipt.js czechrailways.json czechrailways.js deutschebahn.json deutschebahn.js dinnerbooking.json dinnerbooking.js easyairportparking.json easyairportparking-pkpass.js easyjet.json easyjet.js eurowings.json eurowings.js eurowings-pkpass.js fcmtravel.json fcmtravel.js hertz.js hertz.json iberia.json iberia.js klm.json klm.js koleje-malopolskie.json koleje-malopolskie.js korail.json korail.js lufthansa.json lufthansa-pkpass.js + nationalexpress.json + nationalexpress.js nh-hotels.json nh-hotels.js np4.json np4.js regiojet.json regiojet.js sas.json sas-boardingpass.js sas-receipt.js simplebooking.json simplebooking.js sncf.json sncf.js stansted-express.json stansted-express.js swiss.json swiss.js swiss-pkpass.js travelport-galileo.json travelport-galileo.js trenitalia.json trenitalia.js vgn.json vgn.js vueling.json vueling.js diff --git a/src/extractors/nationalexpress.js b/src/extractors/nationalexpress.js new file mode 100644 index 0000000..3188bf0 --- /dev/null +++ b/src/extractors/nationalexpress.js @@ -0,0 +1,55 @@ +/* + Copyright (c) 2019 Nicolas Fella + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +function parseHtmlBooking(doc) { + + var res = JsonLd.newBusReservation() + + var baseTable = "//tbody/tr/td/table/tr/td/table" + + res.reservationNumber = doc.eval(baseTable + "/tr/td/p/strong")[0].content + + res.underName.name = doc.eval(baseTable + "[4]/tr/td[2]/p/strong")[0].content + + res.reservationFor.departureBusStop.name = doc.eval(baseTable + "[6]/tr[1]/td/h3/span")[1].content + + res.reservationFor.arrivalBusStop.name = doc.eval(baseTable + "[6]/tr[1]/td/h3/span")[2].content + + var theDate = doc.eval(baseTable + "[6]/tr[3]/td/table/tr[2]/td[1]/strong")[0].content + + var depTime = doc.eval(baseTable + "[6]/tr[3]/td/table/tr[2]/td[2]/strong")[0].content + + var arrTime = doc.eval(baseTable + "[6]/tr[3]/td/table/tr[2]/td[3]/strong")[0].content + + res.reservationFor.departureTime = makeDateTime(theDate, depTime) + + res.reservationFor.arrivalTime = makeDateTime(theDate, arrTime) + + res.reservationFor.busNumber = doc.eval(baseTable + "/tr/td/strong")[0].content + + var barcodeUrlSplit = doc.eval("//img[@alt=\"Bar Code\"]")[0].attribute("src").split("/") + + res.reservedTicket.ticketToken = "qrCode:" + decodeURIComponent(barcodeUrlSplit[barcodeUrlSplit.length - 1]) + + return res +} + +function makeDateTime(theDate, theTime) { + return JsonLd.toDateTime(theDate + " " + theTime, "ddd MMM dd hh:mm", "en") +} diff --git a/src/extractors/nationalexpress.json b/src/extractors/nationalexpress.json new file mode 100644 index 0000000..e2bf7cc --- /dev/null +++ b/src/extractors/nationalexpress.json @@ -0,0 +1,12 @@ +{ + "filter": [ + { + "header": "From", + "match": "nationalexpress.com", + "type": "Email" + } + ], + "function": "parseHtmlBooking", + "script": "nationalexpress.js", + "type": "Html" +}