Open Choochmeque opened 1 year ago
pyezviz implements the required the decrypt_image function. Here is a quick POC that downloads the last motion image, decrypts it if encryption is enabled and writes it to disk.
from pyezviz import EzvizClient, EzvizCamera, constants
from pyezviz.utils import decrypt_image
import sys
import pprint
import requests
def main():
client = EzvizClient("email", "password", "eu")
decrypt_key = "decrypt-key"
try:
client.login()
camera = EzvizCamera(client, "serial")
status = camera.status()
pprint.pprint(status)
encryption = status['encrypted']
last_motion_image_url = status['last_alarm_pic']
print(last_motion_image_url)
response = requests.get(last_motion_image_url)
if response.status_code == 200:
image_content = decrypt_image(response.content, decrypt_key) if encryption else response.content
with open("last_motion_image.jpg", "wb") as file:
file.write(image_content)
print("image downloaded")
except BaseException as exp:
print(exp)
return 1
finally:
client.close_session()
if __name__ == '__main__':
sys.exit(main())
I hope @RenierM26 will find time to review the PR :)
Hello! It would be great to have support for encrypted images as well.