(self)
return True
Check if new videos since last refresh.
Check if new videos since last refresh.
Check if new videos since last refresh .
def check_new_videos(self):
        """Check if new videos since last refresh."""
        try:
            interval = self.blink.last_refresh - self.motion_interval * 60
        except TypeError:
            # This is the first start, so refresh hasn't happened yet.
            # No need to check for motion.
            return False

        resp = api.request_videos(self.blink, time=interval, page=1)

        for camera in self.cameras.keys():
            self.motion[camera] = False

        try:
            info = resp["media"]
        except (KeyError, TypeError):
            _LOGGER.warning("Could not check for motion. Response: %s", resp)
            return False

        for entry in info:
            try:
                name = entry["device_name"]
                clip = entry["media"]
                timestamp = entry["created_at"]
                if self.check_new_video_time(timestamp):
                    self.motion[name] = True and self.arm
                    self.last_record[name] = {"clip": clip, "time": timestamp}
            except KeyError:
                _LOGGER.debug("No new videos since last refresh.")

        return True
def check_new_videos ( self ) : try : interval = self . blink . last_refresh - self . motion_interval * 60 except TypeError : # This is the first start, so refresh hasn't happened yet. # No need to check for motion. return False resp = api . request_videos ( self . blink , time = interval , page = 1 ) for camera in self . cameras . keys ( ) : self . motion [ camera ] = False try : info = resp [ "media" ] except ( KeyError , TypeError ) : _LOGGER . warning ( "Could not check for motion. Response: %s" , resp ) return False for entry in info : try : name = entry [ "device_name" ] clip = entry [ "media" ] timestamp = entry [ "created_at" ] if self . check_new_video_time ( timestamp ) : self . motion [ name ] = True and self . arm self . last_record [ name ] = { "clip" : clip , "time" : timestamp } except KeyError : _LOGGER . debug ( "No new videos since last refresh." ) return True