-
Notifications
You must be signed in to change notification settings - Fork 0
/
g.mjs
40 lines (32 loc) · 1.04 KB
/
g.mjs
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
38
39
40
// import WDwloadDlp from 'w-dwload-dlp'
import WDwloadDlp from './src/WDwloadDlp.mjs'
async function test() {
//url
// let url = `https://www.youtube.com/watch?v=uj8hjLyEBmU` //youtube mp4
let url = `https://www.youtube.com/watch?v=fTk0mc946dk` //youtube webm
// let url = `https://www.youtube.com/watch?v=lKoCiBVKQaQ` //youtube webm
// let url = `https://www.bilibili.com/video/BV1JZ421x7q8/?spm_id_from=333.1073.channel.secondary_floor_video.click` //bilibili
//fp
let fp = './test.mp4'
//funProg
let funProg = (prog, nn, na) => {
console.log('prog', `${prog.toFixed(2)}%`, nn, na)
}
//WDwloadDlp
await WDwloadDlp(url, fp, {
clean: true, //單一程序執行時, 事先清除之前暫存檔, 減少浪費硬碟空間
funProg,
})
console.log('done:', fp)
}
test()
.catch((err) => {
console.log('catch', err)
})
// prog 0.49% 1 99
// prog 5.05% 4 99
// ...
// prog 99.00% 98 99
// prog 100.00% 99 99
// done: ./test.mp4
//node --experimental-modules g.mjs