davglass / doorbot

Ring.com Doorbell API
Other
317 stars 55 forks source link

Recordings Not Working #7

Closed vonnieda closed 7 years ago

vonnieda commented 7 years ago

Looks like maybe the API for recordings has changed. I get this for every ID:

Error: API returned Status Code 404
    at IncomingMessage.res.on (/Users/jason/Projects/RingRecap/node_modules/doorbot/doorbot.js:61:21)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1045:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9) undefined

If you don't have time to fix this, would you mind describing how you captured the original dumps? Maybe I can replicate it and fix it.

vonnieda commented 7 years ago

Nevermind on the "how did you capture" question. Got that sorted and now working to determine why recordings not working.

vonnieda commented 7 years ago

I suspect that something about this API has been blacklisted. I used Charles Proxy to proxy requests from the Ring app, checked some responses and compared them. Overall it all looks basically the same, but when Ring requests history it gets good history IDs back and when this API requests history it gets alllllmost the same IDs, but the last few digits are zero. Almost looks like the IDs are being rounded, or something.

Example: From Ring App:

[{
    "id": 6443483651709223703,
    "created_at": "2017-07-16T21:27:26.000Z",
    "answered": false,
    "events": [],
    "kind": "motion",
    "favorite": false,
    "snapshot_url": "",
    "recording": {
        "status": "ready"
    },
    "doorbot": {
        "id": 276XXXX,
        "description": "Front Door"
    }
}, {
    "id": 6443483561514910487,
    "created_at": "2017-07-16T21:27:05.000Z",
    "answered": true,
    "events": [],
    "kind": "ding",
    "favorite": false,
    "snapshot_url": "",
    "recording": {
        "status": "ready"
    },
    "doorbot": {
        "id": 276XXXX,
        "description": "Front Door"
    }
}

From this API:

[
  {
    "id": 6443483651709224000,
    "created_at": "2017-07-16T21:27:26.000Z",
    "answered": false,
    "events": [],
    "kind": "motion",
    "favorite": false,
    "snapshot_url": "",
    "recording": {
      "status": "ready"
    },
    "doorbot": {
      "id": 276XXXX,
      "description": "Front Door"
    }
  },
  {
    "id": 6443483561514911000,
    "created_at": "2017-07-16T21:27:05.000Z",
    "answered": true,
    "events": [],
    "kind": "ding",
    "favorite": false,
    "snapshot_url": "",
    "recording": {
      "status": "ready"
    },
    "doorbot": {
      "id": 276XXXX,
      "description": "Front Door"
    }
  }
davglass commented 7 years ago

Good catch.. Looks like the number is too big for Javascript to handle it :(

Since I'm just JSON.parseing the content, I may have to munge it.. Looking now..

vonnieda commented 7 years ago

Ah, didn't even consider that! I thought I was looking at the raw responses, though, not the parsed ones. Might be mistaken and can't check for a few days.

On Tue, Jul 25, 2017 at 11:56 AM Dav Glass notifications@github.com wrote:

Good catch.. Looks like the number is too big for Javascript to handle it :(

Since I'm just JSON.parseing the content, I may have to munge it.. Looking now..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davglass/doorbot/issues/7#issuecomment-317853788, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIKc0v2npI0k-v7UO2CXfpwSOU2Z150ks5sRkh_gaJpZM4OZa8T .

davglass commented 7 years ago

I'm pretty sure that I was able to reproduce it. The parsed response is rounded by JS since the int is too big for it. I think I have a working RegExp that will convert them to String.

Right now I'm fighting with the 401 that comes back from this API far too often. Seeing if I can work around with with some param changes/re-auth/timers/etc..

davglass commented 7 years ago

Can you give doorbot@2.0.0 a shot? I've refactored it, so your code will need to change. It's all in the readme. But it should fix this and the random 401 errors.

vonnieda commented 7 years ago

Working great now @davglass, thank you!