X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=smart_home%2Fcameras.py;h=e8f164b3c0a6f1529347c79400b1036623a87d58;hb=HEAD;hp=2cf2de40f68c85db2999f00e567cf370c68d152d;hpb=87f478b20c8b24eed6c1e87de47ba01e3d9746ab;p=python_utils.git diff --git a/smart_home/cameras.py b/smart_home/cameras.py index 2cf2de4..e8f164b 100644 --- a/smart_home/cameras.py +++ b/smart_home/cameras.py @@ -1,15 +1,21 @@ #!/usr/bin/env python3 +# © Copyright 2021-2022, Scott Gasch + """Utilities for dealing with the webcams.""" import logging +from typing import Optional +import scott_secrets import smart_home.device as dev logger = logging.getLogger(__name__) class BaseCamera(dev.Device): + """A base class for a webcam device.""" + camera_mapping = { 'cabin_drivewaycam': 'cabin_driveway', 'outside_backyard_camera': 'backyard', @@ -24,10 +30,13 @@ class BaseCamera(dev.Device): super().__init__(name.strip(), mac.strip(), keywords) self.camera_name = BaseCamera.camera_mapping.get(name, None) - def get_stream_url(self) -> str: + def get_stream_url(self) -> Optional[str]: + """Get the URL for the webcam's live stream. Return None on error.""" + name = self.camera_name - assert name is not None + if not name: + return None if name == 'driveway': - return f'http://10.0.0.226:8080/Umtxxf1uKMBniFblqeQ9KRbb6DDzN4/mjpeg/GKlT2FfiSQ/driveway' + return f'http://10.0.0.226:8080/{scott_secrets.SHINOBI_KEY1}/mjpeg/{scott_secrets.SHINOBI_KEY2}/driveway' else: - return f'http://10.0.0.226:8080/Umtxxf1uKMBniFblqeQ9KRbb6DDzN4/mp4/GKlT2FfiSQ/{name}/s.mp4' + return f'http://10.0.0.226:8080/{scott_secrets.SHINOBI_KEY1}/mp4/{scott_secrets.SHINOBI_KEY2}/{name}/s.mp4'