Add proxy support back to recording snap()
This commit is contained in:
@@ -41,10 +41,11 @@ class RecordingAPIMixin:
|
||||
proxies={"host": "127.0.0.1", "port": 8000}) as rtsp_client:
|
||||
rtsp_client.preview()
|
||||
|
||||
def get_snap(self, timeout: int = 3) -> Image or None:
|
||||
def get_snap(self, timeout: int = 3, proxies=None) -> Image or None:
|
||||
"""
|
||||
Gets a "snap" of the current camera video data and returns a Pillow Image or None
|
||||
:param timeout: Request timeout to camera in seconds
|
||||
:param proxies: http/https proxies to pass to the request object.
|
||||
:return: Image or None
|
||||
"""
|
||||
data = {}
|
||||
@@ -56,7 +57,7 @@ class RecordingAPIMixin:
|
||||
parms = parse.urlencode(data).encode("utf-8")
|
||||
|
||||
try:
|
||||
response = requests.get(self.url, params=parms, timeout=timeout)
|
||||
response = requests.get(self.url, proxies=proxies, params=parms, timeout=timeout)
|
||||
if response.status_code == 200:
|
||||
return Image.open(BytesIO(response.content))
|
||||
print("Could not retrieve data from camera successfully. Status:", response.stats_code)
|
||||
|
||||
Reference in New Issue
Block a user