Skip to content

Commit

Permalink
Merge pull request #161 from jeanmatthieud/fix-merlin-opening-times
Browse files Browse the repository at this point in the history
Fixes the Merlin parks issues
  • Loading branch information
cubehouse authored May 29, 2019
2 parents 77024fd + 4c30e18 commit 5ea8b17
Show file tree
Hide file tree
Showing 8 changed files with 7,283 additions and 285 deletions.
156 changes: 29 additions & 127 deletions lib/merlinparks/altontowers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

var MerlinPark = require("./index");
const defaultFallbackData = require("./altontowers_data.json");

/**
* Alton Towers
Expand All @@ -14,17 +15,18 @@ class AltonTowers extends MerlinPark {
constructor(options = {}) {
options.name = options.name || "Alton Towers";
options.timezone = options.timezone || "Europe/London";
options.useragent = "okhttp/3.2.0";

// set park's location as it's entrance
options.latitude = options.latitude || 52.991064;
options.longitude = options.longitude || -1.892292;

// Park API options
options.api_key = options.api_key || "5bf34ca0-1428-4163-8dde-f4db4eab6683";
options.initial_data_version = options.initial_data_version || "2017-06-08T08:06:24Z";
options.initial_data_version = options.initial_data_version || "2019-05-01T14:58:20Z";

// where the calendar API is hosted for opening times
options.calendar_base = "https://www.altontowers.com/";
// Fallback data if the /data webservice doesn't work
options.fallback_data = options.fallback_data || defaultFallbackData;

// inherit from base class
super(options);
Expand All @@ -41,130 +43,30 @@ class AltonTowers extends MerlinPark {
});
});
}

FetchOpeningTimes() {
return this.HTTP({
url: `https://www.altontowers.com/Umbraco/Api/OpeningTimes/GetAllAttractionOpeningTimes`,
method: "GET",
headers: {
"Referer": "https://www.altontowers.com/useful-info/opening-times/",
"X-Requested-With": "XMLHttpRequest",
}
}).then((calendarData) => {
// find theme park dates from response
// it also contains "waterpark", "treetopquest", "extraordinarygolf" and "altontowersspa" [sic] times as well in a separate array
if (calendarData.Attractions) {
var themeParkOpeningTimes = calendarData.Attractions.find((item) => item.Attraction === 'themepark');
if (themeParkOpeningTimes && themeParkOpeningTimes.DateRanges) {
for (let i = 0, timeRange; timeRange = themeParkOpeningTimes.DateRanges[i++];) {
let isClosed = timeRange.IsClosed === true || timeRange.OpeningHours === "Closed"; // Best API ever !
this.applyDateRange(timeRange.StartDate, timeRange.EndDate, !isClosed, timeRange.OpeningHours);
}
return;
}
}
});
}
}

module.exports = AltonTowers;

/* eslint-disable */
var dataCache = [{
"_id": "4188",
"Name": "Nemesis"
},
{
"_id": "4189",
"Name": "Galactica"
},
{
"_id": "4190",
"Name": "The Blade"
},
{
"_id": "4192",
"Name": "Oblivion"
},
{
"_id": "4193",
"Name": "The Smiler"
},
{
"_id": "4194",
"Name": "Spinball Whizzer"
},
{
"_id": "4195",
"Name": "Rita"
},
{
"_id": "4196",
"Name": "TH13TEEN"
},
{
"_id": "4197",
"Name": "Runaway Mine Train"
},
{
"_id": "4205",
"Name": "Octonauts Rollercoaster Adventure"
},
{
"_id": "4206",
"Name": "Postman Pat Parcel Post"
},
{
"_id": "4208",
"Name": "Duel - The Haunted House Strikes Back"
},
{
"_id": "4209",
"Name": "In The Night Garden Magical Boat Ride"
},
{
"_id": "4210",
"Name": "Mr. Bloom's Allotment"
},
{
"_id": "4211",
"Name": "Justin's House Pie-O-Matic Factory"
},
{
"_id": "4214",
"Name": "Marauder's Mayhem"
},
{
"_id": "4216",
"Name": "Charlie and Lola's Moonsquirters & Greendrops"
},
{
"_id": "4217",
"Name": "The Numtums Number-Go-Round"
},
{
"_id": "4219",
"Name": "Get Set Go Tree Top Adventure"
},
{
"_id": "4221",
"Name": "Frog Hopper"
},
{
"_id": "4223",
"Name": "Heave Ho"
},
{
"_id": "4224",
"Name": "Gallopers Carousel"
},
{
"_id": "4225",
"Name": "Congo River Rapids"
},
{
"_id": "4227",
"Name": "Enterprise"
},
{
"_id": "4231",
"Name": "Battle Galleons"
},
{
"_id": "4505",
"Name": "Hex - The Legend of the Towers"
},
{
"_id": "4524",
"Name": "Cuckoo Cars Driving School"
},
{
"_id": "4525",
"Name": "Go Jetters Vroomster Zoom Ride"
},
{
"_id": "4533",
"Name": "The Furchester Hotel Live Show"
},
{
"_id": "4773",
"Name": "Wicker Man"
}
];
/* eslint-enable */
Loading

0 comments on commit 5ea8b17

Please sign in to comment.