Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I lock a recording? #25

Closed
mdrobniu opened this issue Oct 19, 2020 · 1 comment
Closed

How do I lock a recording? #25

mdrobniu opened this issue Oct 19, 2020 · 1 comment

Comments

@mdrobniu
Copy link

Hey

Is the locking recording function implemented?

Thanks

@yuppity
Copy link
Owner

yuppity commented Oct 19, 2020

It's not. I'll look into adding it within the next couple of days.


Suggestion in case anyone gets in the mood to write a PR before then:

def refresh(self):
    '''Refetch recording from UniFi Video
    '''
    # ...

def _lock(self, remove=False, verify=True, force=False, check_in_progress=True):
    '''Lock or unlock recording

    Arguments:
        remove (bool):
            Unlock locked recording
        verify (bool):
            Refetch recording data to verify UniFi Video registered the lock
        force (bool):
            Force operation when self.locked matches wanted state
        check_in_progress(bool):
            Throw if recording is in progress
    '''
    if self.in_progress:
        if check_in_progress:
            self.refresh()
            return self._lock(..., check_in_progress=False)
        raise UnifiVideoRecordingInProgressError()

    if self.locked is not remove and not force:
        return True

    # ...

def lock(self, **kwargs):
    '''Lock recording
    '''
    return self._lock(remove=False, **kwargs)

def unlock(self, **kwargs):
    '''Unlock recording
    '''
    return self._lock(remove=True, **kwargs)

The self is UnifiVideoRecording and the force kwarg is probably unnecessary.

yuppity added a commit that referenced this issue Oct 20, 2020
- UnifiVideoRecording.lock: Wraps ._control_lock()
- UnifiVideoRecording.unlock: Wraps ._control_lock()
- UnifiVideoRecording._control_lock: Control recording's lock state
- UnifiVideoRecording.refresh: Refetch recording's state

Related GH issues: #25
yuppity added a commit that referenced this issue Feb 10, 2021
Added
=====
- Support locking and unlocking recordings (closes GH #25)
- Exposed camera UUIDs (see GH PR #29)
- Exposed camera host addresses (closes GH #27)

Changed
=======
- The `width=600` parameter of `UnifiVideoRecording.snapshot()` is now
  `width=0`.  The change matches the behaviour of
  `UnifiVideoCamera.snapshot()` in that unless explicitly given, the
  width is determined by the UniFi Video server. See GH PR #29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants