epg-grabber 0.29.5 → 0.29.7

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.
@@ -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, 1)
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,10 @@ async function main() {
72
72
 
73
73
  let programs = []
74
74
  let i = 1
75
- let days = options.days || 1
75
+ let days = config.days || 1
76
76
  const total = channels.length * days
77
77
  const utcDate = getUTCDate()
78
- const dates = Array.from({ length: config.days }, (_, i) => utcDate.add(i, 'd'))
78
+ const dates = Array.from({ length: days }, (_, i) => utcDate.add(i, 'd'))
79
79
  for (let channel of channels) {
80
80
  if (!channel.logo && config.logo) {
81
81
  channel.logo = await grabber.loadLogo(channel)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epg-grabber",
3
- "version": "0.29.5",
3
+ "version": "0.29.7",
4
4
  "description": "Node.js CLI tool for grabbing EPG from different sites",
5
5
  "main": "src/index.js",
6
6
  "preferGlobal": true,
@@ -5,6 +5,7 @@ dayjs.extend(utc)
5
5
 
6
6
  module.exports = {
7
7
  site: 'example.com',
8
+ days: 2,
8
9
  channels: 'example.channels.xml',
9
10
  output: 'tests/output/guide.xml',
10
11
  url: () => 'http://example.com/20210319/1tv.json',
@@ -1,4 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8" ?><tv date="20221120">
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="20221120">
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>
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 result = execSync(
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(result)).toBe(true)
22
+ expect(stdoutResultTester(stdout)).toBe(true)
23
23
  })
24
24
 
25
25
  it('can load mini config', () => {
26
- const result = execSync(
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(result)).toBe(true)
42
- expect(result.includes("File 'tests/__data__/output/mini.guide.xml' successfully saved")).toBe(
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 result = execSync(
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(result)).toBe(true)
60
- expect(result.includes("File 'tests/__data__/output/mini.guide.xml.gz' successfully saved")).toBe(
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 result = execSync(
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 \
@@ -5,7 +5,7 @@ import fs from 'fs'
5
5
  it('can load config', () => {
6
6
  const config = loadConfig(require(path.resolve('./tests/__data__/input/example.config.js')))
7
7
  expect(config).toMatchObject({
8
- days: 1,
8
+ days: 2,
9
9
  delay: 3000,
10
10
  lang: 'en',
11
11
  site: 'example.com'