-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.js
37 lines (29 loc) · 932 Bytes
/
example.js
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
37
const Videox = require('.')
const path = require('path')
const { exit } = require('process')
const targetUrl1 = 'https://www.youtube.com/watch?v=h32FxBqmu_U'
const targetUrl2 = 'https://www.bilibili.com/video/BV13D4y1o7rj'
const targetUrl = process.env.NODE_ENV === 'test' ? targetUrl1 : targetUrl2
run()
.then(() => exit(0))
.catch((e) => {
console.error(e)
exit(1)
})
async function run() {
const videox = new Videox({
debug: true,
headless: process.env.NODE_ENV === 'test' ? true : false,
downloadBrowser: process.env.NODE_ENV === 'test' ? true : false,
logTo: process.stdout,
browserExecutePath: '/usr/bin/chromium',
browserArgs: ['--no-sandbox'],
downloadAsFile: true,
downloadPath: path.join(__dirname, 'download'),
checkCompleteLoopInterval: 100,
waitForNextDataTimeout: 8000,
})
await videox.init()
await videox.get(targetUrl)
await videox.destroy()
}