Skip to content

Commit 00c00ec

Browse files
committed
Add proxy support back to recording snap()
1 parent ad08a8c commit 00c00ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api/recording.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ def open_video_stream(self, profile: str = "main") -> Image:
4141
proxies={"host": "127.0.0.1", "port": 8000}) as rtsp_client:
4242
rtsp_client.preview()
4343

44-
def get_snap(self, timeout: int = 3) -> Image or None:
44+
def get_snap(self, timeout: int = 3, proxies=None) -> Image or None:
4545
"""
4646
Gets a "snap" of the current camera video data and returns a Pillow Image or None
4747
:param timeout: Request timeout to camera in seconds
48+
:param proxies: http/https proxies to pass to the request object.
4849
:return: Image or None
4950
"""
5051
data = {}
@@ -56,7 +57,7 @@ def get_snap(self, timeout: int = 3) -> Image or None:
5657
parms = parse.urlencode(data).encode("utf-8")
5758

5859
try:
59-
response = requests.get(self.url, params=parms, timeout=timeout)
60+
response = requests.get(self.url, proxies=proxies, params=parms, timeout=timeout)
6061
if response.status_code == 200:
6162
return Image.open(BytesIO(response.content))
6263
print("Could not retrieve data from camera successfully. Status:", response.stats_code)

0 commit comments

Comments
 (0)