Updating dev-1.0.
This commit is contained in:
@@ -23,7 +23,7 @@ class APIHandler:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, ip: str, username: str, password: str, **kwargs):
|
def __init__(self, ip: str, username: str, password: str, https = False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialise the Camera API Handler (maps api calls into python)
|
Initialise the Camera API Handler (maps api calls into python)
|
||||||
:param ip:
|
:param ip:
|
||||||
@@ -34,8 +34,9 @@ class APIHandler:
|
|||||||
More information on proxies in requests: https://stackoverflow.com/a/15661226/9313679
|
More information on proxies in requests: https://stackoverflow.com/a/15661226/9313679
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
scheme = 'https' if https else 'http'
|
||||||
|
self.url = f"{scheme}://{ip}/cgi-bin/api.cgi"
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.url = "http://" + ip + "/cgi-bin/api.cgi"
|
|
||||||
self.token = None
|
self.token = None
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from APIHandler import APIHandler
|
|||||||
|
|
||||||
class Camera(APIHandler):
|
class Camera(APIHandler):
|
||||||
|
|
||||||
def __init__(self, ip, username="admin", password=""):
|
def __init__(self, ip, username="admin", password="", https=False):
|
||||||
"""
|
"""
|
||||||
Initialise the Camera object by passing the ip address.
|
Initialise the Camera object by passing the ip address.
|
||||||
The default details {"username":"admin", "password":""} will be used if nothing passed
|
The default details {"username":"admin", "password":""} will be used if nothing passed
|
||||||
@@ -12,11 +12,11 @@ class Camera(APIHandler):
|
|||||||
:param password:
|
:param password:
|
||||||
"""
|
"""
|
||||||
# For when you need to connect to a camera behind a proxy
|
# For when you need to connect to a camera behind a proxy
|
||||||
APIHandler.__init__(self, ip, username, password, proxy={"http": "socks5://127.0.0.1:8000"})
|
APIHandler.__init__(self, ip, username, password, proxy={"http": "socks5://127.0.0.1:8000"}, https=https)
|
||||||
|
|
||||||
# Normal call without proxy:
|
# Normal call without proxy:
|
||||||
# APIHandler.__init__(self, ip, username, password)
|
# APIHandler.__init__(self, ip, username, password)
|
||||||
|
|
||||||
self.ip = ip
|
self.ip = ip
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Request:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
headers = {'content-type': 'application/json'}
|
headers = {'content-type': 'application/json'}
|
||||||
r = requests.post(url, params=params, json=data, headers=headers, proxies=Request.proxies)
|
r = requests.post(url, verify=False, params=params, json=data, headers=headers, proxies=Request.proxies)
|
||||||
# if params is not None:
|
# if params is not None:
|
||||||
# r = requests.post(url, params=params, json=data, headers=headers, proxies=proxies)
|
# r = requests.post(url, params=params, json=data, headers=headers, proxies=proxies)
|
||||||
# else:
|
# else:
|
||||||
@@ -43,7 +43,7 @@ class Request:
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
data = requests.get(url=url, params=params, timeout=timeout, proxies=Request.proxies)
|
data = requests.get(url=url, verify=False, params=params, timeout=timeout, proxies=Request.proxies)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user