Minor cleanups and some new example programs.#67
Minor cleanups and some new example programs.#67phbcanada wants to merge 12 commits intoReolinkCameraAPI:masterfrom
Conversation
Loosen restrictions.
Improvements to share common code. Fix threaded version to open window in main thread.
Forgot to commit with previous. New method: stop_stream.
New camera method: is_logged_in
New example program to set ftp parameters.
get_info calls all the info methods. snap will snap a single frame image.
Getting occasional garbage back from the cameras which causes the json conversion to crap out. Print some info when this happens.
Benehiko
left a comment
There was a problem hiding this comment.
Hey @phbcanada
Thank you for the contribution! This looks quite good and we should easily be able to merge it :)
Just one question about the version specifier inside the setup.py file.
| 'numpy>=1.19.4', | ||
| 'opencv-python>=4.4.0.46', | ||
| 'Pillow>=8.0.1', | ||
| ], |
There was a problem hiding this comment.
I'm not sure I agree with the inclusive ordered comparison >=. Minor versions could introduce breaking changes at some point. I would rather stick with a specific version and in this case update the specific version manually to a later release.
There was a problem hiding this comment.
The install failed on one of my systems so this was the easy fix. Not a big issue for me.
|
Could we also use conventional commits on the PR title? I know this repository doesn't have any real guidelines on this and in the past it's been quite lax, but I think it is good practice. you can change the title to something like |
|
I haven't used git/github for several years. Not really up on current conventions. Sorry. |
np :) |
The GetAbility command returns a property named "scheduleVersion" which indicates which API calls should be used. The new ones have a "V20" tacked onto the command name.
|
Any chances to get this merged? The set_network_ftp() method would be really helpful. |
There looks to be a simple requested change that still needs to be done. |
Improve set_osd call. Extend FTP setting support. Add set_network_ntp Add set_network_email Fixes to add_user and modify_user.
GetAlarm is not supported on newer cameras.
Correct call is "SetEnc" not "SetRec". Argument types changed.
Benehiko
left a comment
There was a problem hiding this comment.
Looks good, just some minor changes. The setup.py is a bit concerning, IMO it needs to be fixed versions.
| body = [{"cmd": "SetOsd", # "action": 1, | ||
| "param": { | ||
| "Osd": { | ||
| "bgcolor": bg_color, | ||
| # "bgcolor": bg_color, |
| "pos": osd_time_pos}, | ||
| "watermark": int(osd_watermark_enabled), | ||
| }}}] | ||
| # print("SetOsd:", json.dumps(body[0], indent=4)) |
| }}}] | ||
| self._execute_command('SetNetPort', body, multi=True) | ||
| print("Successfully Set Network Ports") | ||
| # print("Successfully Set Network Ports") |
There was a problem hiding this comment.
| # print("Successfully Set Network Ports") | |
| print("Successfully Set Network Ports") |
| ] | ||
| r_data = self._execute_command('ModifyUser', body)[0] | ||
| if r_data["value"]["rspCode"] == 200: | ||
| # print(f"modify user: {username}\nCamera responded with: {json.dumps(r_data, indent=4)}") |
There was a problem hiding this comment.
| # print(f"modify user: {username}\nCamera responded with: {json.dumps(r_data, indent=4)}") |
| param = {"cmd": "Login", "token": "null"} | ||
| response = Request.post(self.url, data=body, params=param) | ||
| if response is not None: | ||
| # print("LOGIN GOT: ", response.text) |
There was a problem hiding this comment.
| # print("LOGIN GOT: ", response.text) |
| """ | ||
| try: | ||
| # Suppress only the single warning from urllib3 needed. | ||
| requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning) |
There was a problem hiding this comment.
maybe make this optional?
or what about just leaving this to the client to set this as an env variable
PYTHONWARNINGS="ignore:Unverified HTTPS request"| # print("Login success") | ||
| else: | ||
| # print(self.token) |
There was a problem hiding this comment.
remove the comments or restore the print of "Login success?"
The threaded streaming example program wasn't working so I fixed it.
The new "set_ftp" example is useful for me since I use FTP to record all my camera motion videos.
The "snap" example is useful for grabbing snapshots from each camera.
I use hostnames instead of IP addresses for my cameras. Just put the IP addresses in /etc/hosts.