项目作者: yuppity

项目描述 :
Python API for UniFi Video
高级语言: Python
项目地址: git://github.com/yuppity/unifi-video-api.git
创建时间: 2018-12-15T13:17:03Z
项目社区:https://github.com/yuppity/unifi-video-api

开源协议:MIT License

下载


unifi-video-api

Build Status
Documentation Status

Python API for interfacing with UniFi Video.

Supported UniFi Video versions: v3.9.12 to v3.10.13

Supported Ubiquiti camera models: UVC, UVC G3, UVC G3 Dome, UVC Dome, UVC Pro, UVC G3 Pro,
UVC G3 Flex, UVC Micro, UVC G3 Micro, airCam, airCam Dome, and airCam Mini, UVC G4 Bullet, UVC G4 Pro.

Features

For a single UniFi Video server:

  • Support both username/password and API key auths
  • Provide GET, POST, PUT, and DELETE methods
  • Handle session tracking and login when necessary
  • Provide iterable collections for cameras and recordings that the UniFi Video server
    is aware of

Per camera:

  • Set or show picture settings: brightness, contrast, saturation, hue, denoise,
    sharpness, dynamic range
  • Set or show IR led state
  • Set or show on-display text
  • Set or show timestamp state
  • Set or show watermark/logo state
  • Set recording mode to fulltime, motion, or disabled
  • Set recording pre/post padding
  • Take and download pictures (snapshots)
  • Download camera footage between arbitrary start and end times

Per recording:

  • Delete
  • Download
  • Snapshot (thumbnail) download

Installation

Either grab it from PyPI

  1. pip install unifi-video

or download a release and manually place unifi_video in your project
directory, or any path in $PYTHONPATH.

You shouldn’t need any external libraries, unless you want to run the tests or
build the docs (see requirements_dev.txt).
unifi-video-api does use the six library but
will fallback to using the included six should it fail to import six from
system level packages.

Both python 2.7+ and python3 are supported.

Usage

See the docs for an API reference.

  1. from unifi_video import UnifiVideoAPI
  2. # Default kwargs: addr = 'localhost', port = 7080, schema = http
  3. uva = UnifiVideoAPI(username='username', password='password', addr='10.3.2.1')
  4. # Use API key (can be set per user in Unifi NVR user settings)
  5. uva = UnifiVideoAPI(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', addr='10.3.2.1')
  6. # Skip version checking
  7. uva = UnifiVideoAPI(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', addr='10.3.2.1',
  8. check_ufv_version=False)
  9. # Use HTTPS and skip cert verification
  10. uva = UnifiVideoAPI(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', addr='10.3.2.1',
  11. port=7443, schema='https', verify_cert=False)
  12. # Save snapshot from camera whose id, name or onscreen display text
  13. # is "Garage"
  14. uva.get_camera('Garage').snapshot('some/path/snapshot.jpg')
  15. # List all cameras UniFi Video is aware of
  16. for camera in uva.cameras:
  17. print(camera)
  18. # Save snapshot from every currently online camera managed by the UniFi Video
  19. # instance. Default filepath: # ./snapshot_{camera ID}_{timestamp}.jpg
  20. for camera in uva.active_cameras:
  21. camera.snapshot()
  22. # List all cameras managed by the UniFi Video instance, online or not
  23. for camera in uva.managed_cameras:
  24. camera.snapshot()
  25. # Get footage from camera "Garage" for specific timespan.
  26. # (The resulting file will be 0 bytes when no footage is found.)
  27. uva.get_camera('Garage').recording_between('2018-12-01 00:00:00',
  28. '2018-12-01 00:05:00')
  29. # Specify filename
  30. uva.get_camera('Garage').recording_between('2018-12-01 00:00:00',
  31. '2018-12-01 00:05:00', 'first_mins_of_dec.mp4')
  32. # Change onscreen display text
  33. uva.get_camera('Garage').set_onscreen_text('Home garage')
  34. # Set IR leds to auto mode
  35. uva.get_camera('Garage').ir_leds('auto')
  36. # Turn off IR leds (manual mode implied)
  37. uva.get_camera('Garage').ir_leds('off')
  38. # Turn on IR leds (manual mode implied)
  39. uva.get_camera('Garage').ir_leds('on')
  40. # Set camera to record at all times and to pre capture 5 secs
  41. uva.get_camera('Garage').set_recording_settings('fulltime',
  42. pre_padding_secs=5)
  43. # Set camera to record motion events only
  44. uva.get_camera('Garage').set_recording_settings('motion')
  45. # Disable recording altogether
  46. uva.get_camera('Garage').set_recording_settings('disable')
  47. # List recordings whose details were fetched during initialization
  48. for rec in uva.recordings:
  49. print(rec)
  50. # Download recording, write to local file recording01.mp4
  51. uva.recordings['xxxxxxxxxxxxxxxxxxxx'].download('recording01.mp4')

Warning

This software has been tested against a limited set of API versions and hardware.
While unlikely, should any of the POST payloads result in software or
hardware failure, the maintainer of this package is not liable.

Proceed at your own risk.