epg-grabber 0.29.0 → 0.29.1
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/package.json +1 -1
- package/src/index.js +4 -0
- package/tests/index.test.js +5 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -27,6 +27,10 @@ class EPGGrabber {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async grab(channel, date, cb = () => {}) {
|
|
30
|
+
if (!(channel instanceof Channel)) {
|
|
31
|
+
throw new Error('The first argument must be the "Channel" class')
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
await sleep(this.config.delay)
|
|
31
35
|
|
|
32
36
|
date = typeof date === 'string' ? getUTCDate(date) : date
|
package/tests/index.test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jest-environment node
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { EPGGrabber } from '../src/index'
|
|
5
|
+
import { EPGGrabber, Channel } from '../src/index'
|
|
6
6
|
import axios from 'axios'
|
|
7
7
|
|
|
8
8
|
jest.mock('axios')
|
|
@@ -20,13 +20,13 @@ it('return "Connection timeout" error if server does not response', done => {
|
|
|
20
20
|
},
|
|
21
21
|
parser: () => []
|
|
22
22
|
}
|
|
23
|
-
const channel = {
|
|
23
|
+
const channel = new Channel({
|
|
24
24
|
site: 'example.com',
|
|
25
25
|
site_id: 'cnn',
|
|
26
26
|
xmltv_id: 'CNN.us',
|
|
27
27
|
lang: 'en',
|
|
28
28
|
name: 'CNN'
|
|
29
|
-
}
|
|
29
|
+
})
|
|
30
30
|
const grabber = new EPGGrabber(config)
|
|
31
31
|
grabber.grab(channel, '2022-01-01', (data, err) => {
|
|
32
32
|
expect(err.message).toBe('Connection timeout')
|
|
@@ -47,13 +47,13 @@ it('can grab single channel programs', done => {
|
|
|
47
47
|
url: 'http://example.com/20210319/1tv.json',
|
|
48
48
|
parser: () => []
|
|
49
49
|
}
|
|
50
|
-
const channel = {
|
|
50
|
+
const channel = new Channel({
|
|
51
51
|
site: 'example.com',
|
|
52
52
|
site_id: '1',
|
|
53
53
|
xmltv_id: '1TV.fr',
|
|
54
54
|
lang: 'fr',
|
|
55
55
|
name: '1TV'
|
|
56
|
-
}
|
|
56
|
+
})
|
|
57
57
|
const grabber = new EPGGrabber(config)
|
|
58
58
|
grabber
|
|
59
59
|
.grab(channel, '2022-01-01', (data, err) => {
|