-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event stream parsing cannot handle arrays #204
Comments
would a try/except edit: drop mention |
I think something like that seems reasonable. I'm not sure what the original regex is designed to accomplish, it was added in #162 to handle the AD110. As long as there is a good way to handle this while not breaking the doorbell functionality, that would be great. I don't have one to test, though. |
It looks like the first two characters after the ContentLength is specified are a carriage return. This has thrown off the json string parsing leading to hand rolling regex which fails in odd ways (see tchellomello#204). Now, pull out a couple extra characters to get past this leading carriage return. If the leading characters are not there, we should have a trailing \r\n\r\n which is safe to add, and will just be stripped out. With this change in place, we are able to use json parsing on data, with a fallback to sending the data string.
It looks like the first two characters after the ContentLength is specified are a carriage return. This has thrown off the json string parsing leading to hand rolling regex which fails in odd ways (see tchellomello#204). Now, pull out a couple extra characters to get past this leading carriage return. If the leading characters are not there, we should have a trailing \r\n\r\n which is safe to add, and will just be stripped out. With this change in place, we are able to use json parsing on data, with a fallback to sending the data string.
I think this is addressed in #212 that makes the change to be able to |
It seems the
_build_payload
function in src/amcrest/event.py cannot handle JSON style arrays as provided by my camera event stream.Package:
amcrest==1.9.3
Camera Details:
Event as seen by curl:
Parsed as:
Issue,
'RegionName'
value is parsed as'['
where[ "Driveway" ]
would be expected.Another example event:
Parsed as:
From what I see in my camera, it may be safe to assume
data={
can parse as JSON.The text was updated successfully, but these errors were encountered: