Method: UnifiProtect::API#video_export

Defined in:
lib/unifi_protect/api.rb

#video_export(camera:, start_time:, end_time:, local_file: nil) ⇒ Object



160
161
162
163
164
165
166
167
# File 'lib/unifi_protect/api.rb', line 160

def video_export(camera:, start_time:, end_time:, local_file: nil)
  start_ts = start_time.utc.to_i * 1000
  end_ts = end_time.utc.to_i * 1000
  local_file ||= "#{camera}_#{start_ts}_#{end_ts}.mp4"

  query = URI.encode_www_form(camera: camera, start: start_ts, end: end_ts)
  download_file(uri(path: 'video/export', query: query), local_file: local_file)
end