python-amcrest
python-amcrest copied to clipboard
AD410 400 Error
Hello, Tried to use the get-files.py example, and it threw a 400 Client Error: $ python3 /home/elliott/get-files.py <Front Door:Z1703D3F0C140> Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http://192.168.2.145:80/cgi-bin/mediaFileFind.cgi?action=findFile&object=1831397672&condition.Channel=0&condition.StartTime=2021-07-10%2001:20:15.936236&condition.EndTime=2021-07-10%2007:20:15.936236') <Front Door:Z1703D3F0C140> Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http://192.168.2.145:80/cgi-bin/mediaFileFind.cgi?action=findFile&object=1831397672&condition.Channel=0&condition.StartTime=2021-07-10%2001:20:15.936236&condition.EndTime=2021-07-10%2007:20:15.936236') <Front Door:Z1703D3F0C140> Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http://192.168.2.145:80/cgi-bin/mediaFileFind.cgi?action=findFile&object=1831397672&condition.Channel=0&condition.StartTime=2021-07-10%2001:20:15.936236&condition.EndTime=2021-07-10%2007:20:15.936236') Traceback (most recent call last): File "/home/elliott/.local/lib/python3.8/site-packages/amcrest/http.py", line 204, in _command resp.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://192.168.2.145:80/cgi-bin/mediaFileFind.cgi?action=findFile&object=1831397672&condition.Channel=0&condition.StartTime=2021-07-10%2001:20:15.936236&condition.EndTime=2021-07-10%2007:20:15.936236
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/elliott/get-files.py", line 23, in
You might want to try using Channel 1 (add ",1" to the file_find function).
I've made some changes to media.py to get it working on my IP5M-B1186EW as there are some other issues against the latest API documentation, namely
- action=factory.close should be action=close
- action=factory.destroy should be action=destroy.
- default channel should by 1(?)
@tchellomello, Not sure how the changes apply to backward compatibility. Do you want me to issue a PR for review?
@wizmo2 , changing to action=close and action=destroy resolved the issue for me. Can you make a PR for that? (Or I can do it)
What is weird, I definitely remember that factory.close and factory.destroy worked for me (~2 years ago). But not now. I am not sure what changed (my Amcrest camera is still the same).
Does it make sense to do:
try:
ret = self.command(
f"mediaFileFind.cgi?action=close&object={factory_id}"
)
except:
ret = self.command(
f"mediaFileFind.cgi?action=factory.close&object={factory_id}"
)
?
@maximvelichko, This was I while ago that I looked at this. It would take me a while to go back and see what I did, so go ahead with your own PR.