epg-grabber 0.29.5 → 0.29.6
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/bin/epg-grabber.js +4 -3
- package/package.json +1 -1
- package/tests/__data__/input/example.config.js +1 -0
- package/tests/__data__/output/duplicates.guide.xml +1 -1
- package/tests/__data__/output/mini.guide.xml +1 -1
- package/tests/__data__/output/mini.guide.xml.gz +0 -0
- package/tests/bin.test.js +9 -9
- package/tests/config.test.js +1 -1
package/bin/epg-grabber.js
CHANGED
|
@@ -23,7 +23,7 @@ program
|
|
|
23
23
|
.option('-o, --output <output>', 'Path to output file')
|
|
24
24
|
.option('--channels <channels>', 'Path to channels.xml file')
|
|
25
25
|
.option('--lang <lang>', 'Set default language for all programs')
|
|
26
|
-
.option('--days <days>', 'Number of days for which to grab the program', parseNumber
|
|
26
|
+
.option('--days <days>', 'Number of days for which to grab the program', parseNumber)
|
|
27
27
|
.option('--delay <delay>', 'Delay between requests (in mileseconds)', parseNumber)
|
|
28
28
|
.option('--timeout <timeout>', 'Set a timeout for each request (in mileseconds)', parseNumber)
|
|
29
29
|
.option(
|
|
@@ -72,10 +72,11 @@ async function main() {
|
|
|
72
72
|
|
|
73
73
|
let programs = []
|
|
74
74
|
let i = 1
|
|
75
|
-
let days =
|
|
75
|
+
let days = config.days || 1
|
|
76
76
|
const total = channels.length * days
|
|
77
77
|
const utcDate = getUTCDate()
|
|
78
|
-
const dates = Array.from({ length:
|
|
78
|
+
const dates = Array.from({ length: days }, (_, i) => utcDate.add(i, 'd'))
|
|
79
|
+
console.log(dates)
|
|
79
80
|
for (let channel of channels) {
|
|
80
81
|
if (!channel.logo && config.logo) {
|
|
81
82
|
channel.logo = await grabber.loadLogo(channel)
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?><tv date="
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?><tv date="20230110">
|
|
2
2
|
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>
|
|
3
3
|
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
4
|
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?><tv date="
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?><tv date="20230110">
|
|
2
2
|
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>
|
|
3
3
|
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
4
|
</tv>
|
|
Binary file
|
package/tests/bin.test.js
CHANGED
|
@@ -12,18 +12,18 @@ function stdoutResultTester(stdout) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
it('can load config', () => {
|
|
15
|
-
const
|
|
15
|
+
const stdout = execSync(
|
|
16
16
|
`node ${pwd}/bin/epg-grabber.js --config=tests/__data__/input/example.config.js --delay=0`,
|
|
17
17
|
{
|
|
18
18
|
encoding: 'utf8'
|
|
19
19
|
}
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
expect(stdoutResultTester(
|
|
22
|
+
expect(stdoutResultTester(stdout)).toBe(true)
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
it('can load mini config', () => {
|
|
26
|
-
const
|
|
26
|
+
const stdout = execSync(
|
|
27
27
|
`node ${pwd}/bin/epg-grabber.js \
|
|
28
28
|
--config=tests/__data__/input/mini.config.js \
|
|
29
29
|
--channels=tests/__data__/input/example.channels.xml \
|
|
@@ -38,14 +38,14 @@ it('can load mini config', () => {
|
|
|
38
38
|
}
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
-
expect(stdoutResultTester(
|
|
42
|
-
expect(
|
|
41
|
+
expect(stdoutResultTester(stdout)).toBe(true)
|
|
42
|
+
expect(stdout.includes("File 'tests/__data__/output/mini.guide.xml' successfully saved")).toBe(
|
|
43
43
|
true
|
|
44
44
|
)
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it('can generate gzip version', () => {
|
|
48
|
-
const
|
|
48
|
+
const stdout = execSync(
|
|
49
49
|
`node ${pwd}/bin/epg-grabber.js \
|
|
50
50
|
--config=tests/__data__/input/mini.config.js \
|
|
51
51
|
--channels=tests/__data__/input/example.channels.xml \
|
|
@@ -56,14 +56,14 @@ it('can generate gzip version', () => {
|
|
|
56
56
|
}
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
-
expect(stdoutResultTester(
|
|
60
|
-
expect(
|
|
59
|
+
expect(stdoutResultTester(stdout)).toBe(true)
|
|
60
|
+
expect(stdout.includes("File 'tests/__data__/output/mini.guide.xml.gz' successfully saved")).toBe(
|
|
61
61
|
true
|
|
62
62
|
)
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
it('removes duplicates of the program', () => {
|
|
66
|
-
const
|
|
66
|
+
const stdout = execSync(
|
|
67
67
|
`node ${pwd}/bin/epg-grabber.js \
|
|
68
68
|
--config=tests/__data__/input/duplicates.config.js \
|
|
69
69
|
--channels=tests/__data__/input/example.channels.xml \
|
package/tests/config.test.js
CHANGED