cubehouse / themeparks

Unofficial API for accessing ride wait times and schedules for Disneyland, Disney World, Universal Studios, and many more parks
MIT License
544 stars 126 forks source link

Tokyo Disney Resort fails #146

Closed SomethingWithComputers closed 5 years ago

SomethingWithComputers commented 5 years ago

Park Tokyo Disney Resort (both sea and world)

Context

Describe the bug A clear and concise description of what the bug is.

Output When trying to fetch the waiting times for Tokyo Disney Sea or World, this is always the response:

Error fetching park wait times: 401: {
  "errors": [
    {
      "code": "error.invalid",
      "property": "deviceId"
    }
  ]
}
cubehouse commented 5 years ago

Hi,

Sorry but I can't reproduce this issue. I am running the following with success:

PRINTDATA=true NODE_DEBUG=themeparks PARKID=TokyoDisneyResortMagicKingdom npm run testonline

dotaguro commented 5 years ago

Works for me too, fwiw

On Sat, Mar 30, 2019 at 10:29 AM Jamie Holding notifications@github.com wrote:

Hi,

Sorry but I can't reproduce this issue. I am running the following with success:

PRINTDATA=true NODE_DEBUG=themeparks PARKID=TokyoDisneyResortMagicKingdom npm run testonline

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cubehouse/themeparks/issues/146#issuecomment-478268587, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFZumbnj2CNvAmhA9LAdruthJLqsA44ks5vb57_gaJpZM4cPqhX .

SomethingWithComputers commented 5 years ago

I've only been able to reproduce it on my server, my local version mostly works fine. It seems that the s_deviceID is not set before the call to the API is made when utilising the FetchWaitTimes method. I've solved the issue for now by explicitly adding a call that sets the s_deviceID before fetching the rest of the wait times as such (in Tokyo Disney's index.js file):

        ...
        key: "FetchWaitTimes",
        value: function FetchWaitTimes() {
            var _this4 = this;

            // first get our ride names etc.
            return this.FetchDeviceID().then(function (deviceId) {
                _this4[s_deviceID] = deviceId;
                return _this4.FetchRideData().then(function (rides) {
        ...

I make two call sequentially to both parks in the Tokyo Disney Resort and whichever resort is called second has this bug. I do know my server is running a different version of Node, but I'll check when I get home which one specifically.

cubehouse commented 5 years ago

Thanks for the update, it looks like device ID may be generated separately between parks now.

This should be the fix:

     }

     FetchDeviceID() {
         if (this[s_deviceID]) return Promise.resolve(this[s_deviceID]);

-        return this.Cache.WrapGlobal("tdrDeviceID", () => {
+        return this.Cache.Wrap("tdrDeviceID", () => {
             return this.HTTP({
                 url: `${this[s_apiBase]}/rest/v1/devices`,
                 method: "POST",
                 headers: this.GetAPIHeaders(),
             }).then((data) => {

I'll do some testing and push out a fix if this resolve this.

SomethingWithComputers commented 5 years ago

Great news! Thanks!

cubehouse commented 5 years ago

Pushed out 4.7.14. Let me know if that does or doesn't work :)