Skip to content

Commit

Permalink
Merge branch 'efteling_2024_11'
Browse files Browse the repository at this point in the history
  • Loading branch information
cubehouse committed Nov 17, 2024
2 parents 590edba + 6d74ef1 commit 878f251
Show file tree
Hide file tree
Showing 3 changed files with 14,009 additions and 8 deletions.
31 changes: 23 additions & 8 deletions lib/parks/efteling/efteling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import {attractionType, statusType, queueType, tagType, scheduleType, entityType
import moment from 'moment-timezone';
import Destination from '../destination.js';

// get directory of this script
import { fileURLToPath } from 'url';
import { dirname, join as pathJoin } from 'path';
import { promises as fs } from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

/**
* Efteling Park Object
*/
Expand Down Expand Up @@ -39,6 +46,9 @@ export class Efteling extends Destination {
{
hostname: 'prd-search-acs.efteling.com',
},
{
hostname: 'cloud.efteling.com',
}
],
}, (method, url, data, options) => {
// all requests from the app to any efteling subdomain should send these headers
Expand All @@ -50,7 +60,7 @@ export class Efteling extends Destination {
options.headers['x-app-timezone'] = this.config.timezone;
// override user-agent here, rather than class-wide
// any other non-Efteling API requests can use the default user-agent
options.headers['user-agent'] = 'okhttp/4.4.0';
options.headers['user-agent'] = 'okhttp/4.12.0';
options.compressed = true;
});

Expand All @@ -72,14 +82,19 @@ export class Efteling extends Destination {
// cache for 12 hours
'@cache|720';

// curl -H 'Host: prd-search-acs.efteling.com' -H 'user-agent: okhttp/4.4.0' -H 'x-app-version: v3.7.1' -H 'x-app-name: Efteling' -H 'x-app-id: nl.efteling.android' -H 'x-app-platform: Android' -H 'x-app-language: en' -H 'x-app-timezone: Europe/London' --compressed 'https://prd-search-acs.efteling.com/2013-01-01/search?q.parser=structured&size=1000&q=%28and%20%28phrase%20field%3Dlanguage%20%27en%27%29%29'
const fetchedPOIData = await this.http('GET', this.config.searchUrl, {
'size': 1000,
'q.parser': 'structured',
'q': `(and (phrase field=language \'${language}\'))`,
});
// build path to our JSON data
const jsonDataPath = pathJoin(__dirname, `poi-feed-${language}.json`);

// check if we have a local copy of the POI data
try {
const data = await fs.readFile(jsonDataPath, 'utf8');
const JSONdata = JSON.parse(data);

return fetchedPOIData?.body?.hits?.hit;
return JSONdata?.hits?.hit;
} catch (err) {
// return null if we can't find the file
return null;
}
}

/**
Expand Down
Loading

0 comments on commit 878f251

Please sign in to comment.