From 4ebc0a2c972e4a4bbe6ffddfc548ce0f3207b85b Mon Sep 17 00:00:00 2001 From: Alano Terblanche Date: Sun, 11 Aug 2019 11:24:02 +0200 Subject: [PATCH 1/2] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a9eff6e..20aa9b5 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ You can get the Restful API calls by looking through the HTTP Requests made the Implement a "Camera" object by passing it an IP address, Username and Password. By instantiating the object, it will try retrieve a login token from the Reolink Camera. This token is necessary to interact with the Camera using other commands. +### Styling and Standards + +This project intends to stick with [PEP8](https://www.python.org/dev/peps/pep-0008/) + ### API Requests Implementation Plan: GET: @@ -47,7 +51,7 @@ GET: - [ ] Focus - [ ] Image (Brightness, Contrass, Saturation, Hue, Sharp, Mirror, Rotate) - [ ] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR) -- [ ] Image Data +- [ ] Image Data -> "Snap" Frame from Video Stream SET: - [ ] Display -> OSD From 1f5944801cad877ff2fdd0b1944678ab170f760d Mon Sep 17 00:00:00 2001 From: David Beitey Date: Sun, 15 Sep 2019 11:11:21 +1000 Subject: [PATCH 2/2] Allow API connection over HTTPS --- APIHandler.py | 5 +++-- Camera.py | 5 +++-- resthandle.py | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/APIHandler.py b/APIHandler.py index 2653081..0522f5c 100644 --- a/APIHandler.py +++ b/APIHandler.py @@ -5,8 +5,9 @@ from resthandle import Request class APIHandler: - def __init__(self, ip): - self.url = "http://" + ip + "/cgi-bin/api.cgi" + def __init__(self, ip, https=False): + scheme = 'https' if https else 'http' + self.url = f"{scheme}://{ip}/cgi-bin/api.cgi" self.token = None # Token diff --git a/Camera.py b/Camera.py index 1e82361..63dca91 100644 --- a/Camera.py +++ b/Camera.py @@ -3,9 +3,10 @@ from APIHandler import APIHandler class Camera(APIHandler): - def __init__(self, ip, username="admin", password=""): - APIHandler.__init__(self, ip) + def __init__(self, ip, username="admin", password="", https=False): + APIHandler.__init__(self, ip, https=https) self.ip = ip self.username = username self.password = password + self.https = https super().login(self.username, self.password) diff --git a/resthandle.py b/resthandle.py index e632686..5b1187a 100644 --- a/resthandle.py +++ b/resthandle.py @@ -17,9 +17,9 @@ class Request: try: headers = {'content-type': 'application/json'} if params is not None: - r = requests.post(url, params=params, json=data, headers=headers) + r = requests.post(url, verify=False, params=params, json=data, headers=headers) else: - r = requests.post(url, json=data) + r = requests.post(url, verify=False, json=data) if r.status_code == 200: return r else: @@ -38,7 +38,7 @@ class Request: :return: """ try: - data = requests.get(url=url, params=params, timeout=timeout) + data = requests.get(url=url, verify=False, params=params, timeout=timeout) return data except Exception as e: print("Get Error\n", e)