-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathtest.mjs
36 lines (35 loc) · 1.24 KB
/
test.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
import * as megacubo from './www/nodejs/main.mjs';
//import * as megacubo from 'megacubo';
//const megacubo = require('megacubo');
(async () => {
global.megacubo = megacubo
console.log('init')
megacubo.renderer.ready(null, true) // fake client is "ready"
await megacubo.init('en', 'America/New_York')
megacubo.config.set('enable-console', true)
try {
const urls = [
'http://.../playlist.m3u8'
]
for(let url of urls) {
try {
let ret = await megacubo.lists.manager.add(url, 'test', 'test')
console.log('list added', url, ret)
await megacubo.lists.loader.addListNow(url)
console.log('list added now', url)
} catch (e) {
console.error('Error adding list: ' + e)
}
}
console.log('waiting for lists to be ready...')
await megacubo.lists.ready()
console.table(Object.keys(megacubo.lists.lists))
console.log('seaching for cnn...')
const result = await megacubo.lists.search('cnn')
console.log('result', result)
} catch (e) {
console.error('Error adding list: ' + e)
}
console.log('done.')
await process.exit(0)
})()