forked from dgreif/ring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
record-example.ts
36 lines (30 loc) · 882 Bytes
/
record-example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import 'dotenv/config'
import { RingApi } from '../ring-client-api'
import { cleanOutputDirectory, outputDirectory } from './util'
import * as path from 'path'
/**
* This example records a 10 second video clip to output/example.mp4
**/
async function example() {
const ringApi = new RingApi({
// Replace with your refresh token
refreshToken: process.env.RING_REFRESH_TOKEN!,
debug: true,
}),
cameras = await ringApi.getCameras(),
camera = cameras[0]
if (!camera) {
console.log('No cameras found')
return
}
// clean/create the output directory
await cleanOutputDirectory()
console.log(`Starting Video from ${camera.name} ...`)
await camera.recordToFile(path.join(outputDirectory, 'example.mp4'), 10)
console.log('Done recording video')
process.exit(0)
}
example().catch((e) => {
console.error(e)
process.exit(1)
})