Skip to content
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

AD410 400 Error #177

Open
edk4971 opened this issue Jul 10, 2021 · 3 comments
Open

AD410 400 Error #177

edk4971 opened this issue Jul 10, 2021 · 3 comments

Comments

@edk4971
Copy link

edk4971 commented Jul 10, 2021

Hello,
Tried to use the get-files.py example, and it threw a 400 Client Error:
$ python3 /home/elliott/get-files.py
Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http:https://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')
Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http:https://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')
Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http:https://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:https://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
for text in camera.find_files(start_time, end_time):
File "/home/elliott/.local/lib/python3.8/site-packages/amcrest/media.py", line 134, in find_files
search = self.media_file_find_start(
File "/home/elliott/.local/lib/python3.8/site-packages/amcrest/media.py", line 88, in media_file_find_start
ret = self.command(
File "/home/elliott/.local/lib/python3.8/site-packages/amcrest/http.py", line 169, in command
return self._command(*args, **kwargs)
File "/home/elliott/.local/lib/python3.8/site-packages/amcrest/http.py", line 209, in _command
raise CommError(error)
amcrest.exceptions.CommError: 400 Client Error: Bad Request for url: http:https://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

@wizmo2
Copy link

wizmo2 commented Aug 12, 2021

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?

@maximvelichko
Copy link
Contributor

@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}"
        )

?

@wizmo2
Copy link

wizmo2 commented Jan 12, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants