epg-grabber 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/index.js +6 -0
- package/tests/bin.test.js +3 -6
- package/tests/index.test.js +20 -0
- package/tests/input/example.com.config.js +1 -0
- package/tests/input/mini.config.js +1 -0
- package/tests/utils.test.js +1 -0
package/README.md
CHANGED
|
@@ -94,6 +94,7 @@ module.exports = {
|
|
|
94
94
|
lang: 'fr', // default language for all programs (default: 'en')
|
|
95
95
|
days: 3, // number of days for which to grab the program (default: 1)
|
|
96
96
|
delay: 5000, // delay between requests (default: 3000)
|
|
97
|
+
ignore: true, // skip all channels during request (default: false)
|
|
97
98
|
|
|
98
99
|
request: { // request options (details: https://github.com/axios/axios#request-config)
|
|
99
100
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -14,6 +14,12 @@ module.exports = {
|
|
|
14
14
|
|
|
15
15
|
let programs = []
|
|
16
16
|
for (let item of queue) {
|
|
17
|
+
if (config.ignore) {
|
|
18
|
+
item.programs = []
|
|
19
|
+
cb(item, new Error('Skipped'))
|
|
20
|
+
continue
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
await utils
|
|
18
24
|
.buildRequest(item, config)
|
|
19
25
|
.then(request => utils.fetchData(request))
|
package/tests/bin.test.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const { execSync } = require('child_process')
|
|
2
|
-
const pwd = `${__dirname}/..`
|
|
3
|
-
import axios from 'axios'
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
const pwd = `${__dirname}/..`
|
|
6
4
|
|
|
7
5
|
function stdoutResultTester(stdout) {
|
|
8
6
|
return [`Finish`].every(val => {
|
|
@@ -22,8 +20,6 @@ it('can load config', () => {
|
|
|
22
20
|
})
|
|
23
21
|
|
|
24
22
|
it('can load mini config', () => {
|
|
25
|
-
axios.mockImplementation(() => Promise.resolve({ data: '' }))
|
|
26
|
-
|
|
27
23
|
const result = execSync(
|
|
28
24
|
`node ${pwd}/bin/epg-grabber.js \
|
|
29
25
|
--config=tests/input/mini.config.js \
|
|
@@ -32,7 +28,8 @@ it('can load mini config', () => {
|
|
|
32
28
|
--lang=fr \
|
|
33
29
|
--days=3 \
|
|
34
30
|
--delay=0 \
|
|
35
|
-
--
|
|
31
|
+
--debug \
|
|
32
|
+
--timeout=1`,
|
|
36
33
|
{
|
|
37
34
|
encoding: 'utf8'
|
|
38
35
|
}
|
package/tests/index.test.js
CHANGED
|
@@ -71,3 +71,23 @@ it('can grab single channel programs', done => {
|
|
|
71
71
|
done()
|
|
72
72
|
})
|
|
73
73
|
})
|
|
74
|
+
|
|
75
|
+
it('return "Skipped" error if ignore option in config is true', done => {
|
|
76
|
+
const config = {
|
|
77
|
+
site: 'example.com',
|
|
78
|
+
ignore: true,
|
|
79
|
+
url: `http://example.com/20210319/1tv.json`,
|
|
80
|
+
parser: () => []
|
|
81
|
+
}
|
|
82
|
+
const channel = {
|
|
83
|
+
site: 'example.com',
|
|
84
|
+
site_id: 'cnn',
|
|
85
|
+
xmltv_id: 'CNN.us',
|
|
86
|
+
lang: 'en',
|
|
87
|
+
name: 'CNN'
|
|
88
|
+
}
|
|
89
|
+
grabber.grab(channel, config, (data, err) => {
|
|
90
|
+
expect(err.message).toBe('Skipped')
|
|
91
|
+
done()
|
|
92
|
+
})
|
|
93
|
+
})
|
package/tests/utils.test.js
CHANGED