diff --git a/lib/portaventura/portaventura.js b/lib/portaventura/portaventura.js index b3f0ee10..099c740a 100644 --- a/lib/portaventura/portaventura.js +++ b/lib/portaventura/portaventura.js @@ -26,7 +26,7 @@ class PortAventura extends Park { constructor(options = {}) { options.name = options.name || 'PortAventura'; - // Europa-Park coordinates + // park's coordinates options.latitude = options.latitude || 41.086456; options.longitude = options.longitude || 1.153650; @@ -46,14 +46,19 @@ class PortAventura extends Park { FetchWaitTimes() { return this.HTTP({ - url: `${this[sApiBase]}ws/filters/${this[sParkTitle]}/atraccion/en`, + url: `${this[sApiBase]}ws/nv/filters/${this[sParkTitle]}/atraccion/en`, }).then((rides) => { rides.forEach((ride) => { // parse wait time - const parsedTime = /([-\d]+)(?::(\d+))?/.exec(ride.tiempo_espera); let waitTime = null; - if (parsedTime[1] !== '-1' && parsedTime[2] !== undefined) { - waitTime = (Number(parsedTime[1]) * 60) + Number(parsedTime[2]); + // TODO: find the location_status when a ride is not operational + if (ride.location_status === 0) { + waitTime = -1; + } else if (ride.time_range !== null) { + // time_range = "XX h" or "XX min" or null + // time_sign = "<" or ">" or null (not used) + const [value, unit] = ride.time_range.split(' '); + waitTime = parseInt(value, 10) * (unit === 'min' ? 1 : 60); } // update ride object