epg-grabber 0.46.0 → 0.46.2

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/.prettierrc.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ tabWidth: 2,
3
+ useTabs: false,
4
+ endOfLine: "crlf",
5
+ semi: false,
6
+ singleQuote: true,
7
+ printWidth: 100,
8
+ trailingComma: "none",
9
+ arrowParens: "avoid",
10
+ };
package/README.md CHANGED
@@ -8,61 +8,6 @@ Node.js CLI tool for grabbing EPG from different websites.
8
8
  npm install -g epg-grabber
9
9
  ```
10
10
 
11
- ## Quick Start
12
-
13
- ```sh
14
- epg-grabber --config=example.com.config.js
15
- ```
16
-
17
- #### example.com.config.js
18
-
19
- ```js
20
- module.exports = {
21
- site: 'example.com',
22
- channels: 'example.com.channels.xml',
23
- url: function (context) {
24
- const { date, channel } = context
25
-
26
- return `https://api.example.com/${date.format('YYYY-MM-DD')}/channel/${channel.site_id}`
27
- },
28
- parser: function (context) {
29
- const programs = JSON.parse(context.content)
30
-
31
- return programs.map(program => {
32
- return {
33
- title: program.title,
34
- start: program.start,
35
- stop: program.stop
36
- }
37
- })
38
- }
39
- }
40
- ```
41
-
42
- #### example.com.channels.xml
43
-
44
- ```xml
45
- <?xml version="1.0" ?>
46
- <channels site="example.com">
47
- <channel site_id="cnn-23" xmltv_id="CNN.us">CNN</channel>
48
- </channels>
49
- ```
50
-
51
- ## Example Output
52
-
53
- ```xml
54
- <tv>
55
- <channel id="CNN.us">
56
- <display-name>CNN</display-name>
57
- <url>https://example.com</url>
58
- </channel>
59
- <programme start="20211116040000 +0000" stop="20211116050000 +0000" channel="CNN.us">
60
- <title lang="en">News at 10PM</title>
61
- </programme>
62
- // ...
63
- </tv>
64
- ```
65
-
66
11
  ## CLI
67
12
 
68
13
  ```sh
@@ -86,7 +31,15 @@ Arguments:
86
31
  - `--log`: path to log file (optional)
87
32
  - `--log-level`: set the log level (default: `info`)
88
33
 
89
- ## Site Config
34
+ ## How to use?
35
+
36
+ First, you need to create two files:
37
+
38
+ <details>
39
+ <summary>example.com.config.js</summary>
40
+ <br>
41
+
42
+ This file describes what kind of request we need to send to get the guide for a particular channel on a certain date and how to parse the response.
90
43
 
91
44
  ```js
92
45
  module.exports = {
@@ -182,14 +135,14 @@ module.exports = {
182
135
  }
183
136
  ```
184
137
 
185
- ## Request Context Object
138
+ ### Request Context Object
186
139
 
187
140
  Inside `url()`, `logo()`, `request.data()`, `request.headers()` functions in `config.js` you can access a `context` object containing the following data:
188
141
 
189
142
  - `channel`: The object describing the current channel (xmltv_id, site_id, name, lang)
190
143
  - `date`: The 'dayjs' instance with the requested date
191
144
 
192
- ## Parser Context Object
145
+ ### Parser Context Object
193
146
 
194
147
  Inside `parser()` function in `config.js` you can access a `context` object containing the following data:
195
148
 
@@ -201,7 +154,7 @@ Inside `parser()` function in `config.js` you can access a `context` object cont
201
154
  - `request`: The request config
202
155
  - `cached`: A boolean to check whether this request was cached or not
203
156
 
204
- ## Program Object
157
+ ### Program Object
205
158
 
206
159
  | Property | Aliases | Type | Required |
207
160
  | --------------- | -------------------------------- | ------------------------------------------------ | -------- |
@@ -371,7 +324,13 @@ Example:
371
324
  }
372
325
  ```
373
326
 
374
- ## Channels List
327
+ </details>
328
+
329
+ <details>
330
+ <summary>example.com.channels.xml</summary>
331
+ <br>
332
+
333
+ This file contains a list of channels available at the source.
375
334
 
376
335
  ```xml
377
336
  <?xml version="1.0" ?>
@@ -395,6 +354,29 @@ You can also specify the language, site, url, logo and LCN (Logical Channel Numb
395
354
  >France 24</channel>
396
355
  ```
397
356
 
357
+ </details>
358
+
359
+ After that, you just need to run the grabber with path to the config file:
360
+
361
+ ```sh
362
+ epg-grabber --config=path/to/example.com.config.js
363
+ ```
364
+
365
+ And when the download is complete, a ready-to-use guide will appear in the location you specified:
366
+
367
+ ```xml
368
+ <tv>
369
+ <channel id="CNN.us">
370
+ <display-name>CNN</display-name>
371
+ <url>https://example.com</url>
372
+ </channel>
373
+ <programme start="20211116040000 +0000" stop="20211116050000 +0000" channel="CNN.us">
374
+ <title lang="en">News at 10PM</title>
375
+ </programme>
376
+ // ...
377
+ </tv>
378
+ ```
379
+
398
380
  ## How to use SOCKS proxy?
399
381
 
400
382
  ```
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as name, v as version, d as description, p as parseNumber, l as loadJs, a as parseProxy, E as EPGGrabberMock, b as EPGGrabber, c as defaultConfig, i as isObject, g as getAbsPath, e as getUTCDate } from './index-DUJ5SdIU.js';
2
+ import { n as name, v as version, d as description, p as parseNumber, l as loadJs, a as parseProxy, E as EPGGrabberMock, b as EPGGrabber, c as defaultConfig, i as isObject, g as getAbsPath, e as getUTCDate } from './index-Bnw63KMN.js';
3
3
  import { Collection, Template } from '@freearhey/core';
4
4
  import { Command, Option } from 'commander';
5
5
  import { SocksProxyAgent } from 'socks-proxy-agent';
@@ -102,7 +102,7 @@ function toArray(value) {
102
102
  }
103
103
 
104
104
  var name = "epg-grabber";
105
- var version = "0.46.0";
105
+ var version = "0.46.1";
106
106
  var description = "Node.js CLI tool for grabbing EPG from different sites";
107
107
  var homepage = "https://github.com/freearhey/epg-grabber";
108
108
 
@@ -731,7 +731,7 @@ class EPGGrabber {
731
731
  async loadLogo(channel, date, config = {}) {
732
732
  if (!(channel instanceof Channel))
733
733
  throw new Error('The first argument must be the "Channel" class');
734
- config = merge(defaultConfig, config, this.globalConfig);
734
+ config = merge({}, defaultConfig, config, this.globalConfig);
735
735
  if (typeof config.logo !== "function") return null;
736
736
  const requestContext = { channel, date: getUTCDate(date), config };
737
737
  const logo = config.logo(requestContext);
@@ -749,7 +749,7 @@ class EPGGrabber {
749
749
  config = {};
750
750
  }
751
751
  const utcDate = getUTCDate(date);
752
- config = merge(defaultConfig, config, this.globalConfig);
752
+ config = merge({}, defaultConfig, config, this.globalConfig);
753
753
  if (!config.parser) throw new Error("Could not find parser() in the config file");
754
754
  if (!config.site) throw new Error("The required 'site' property is missing");
755
755
  if (!config.url) throw new Error("The required 'url' property is missing");
@@ -826,7 +826,7 @@ class EPGGrabberMock extends EPGGrabber {
826
826
  config = {};
827
827
  }
828
828
  const utcDate = getUTCDate(date);
829
- config = merge(defaultConfig, config, this.globalConfig);
829
+ config = merge({}, defaultConfig, config, this.globalConfig);
830
830
  if (!config.parser) throw new Error("Could not find parser() in the config file");
831
831
  try {
832
832
  const requestContext = { channel, date: utcDate, config };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- export { C as Channel, b as EPGGrabber, E as EPGGrabberMock, P as Program } from './index-DUJ5SdIU.js';
2
+ export { C as Channel, b as EPGGrabber, E as EPGGrabberMock, P as Program } from './index-Bnw63KMN.js';
3
3
  import 'axios-mock-adapter';
4
4
  import 'lodash.merge';
5
5
  import 'xml-js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epg-grabber",
3
- "version": "0.46.0",
3
+ "version": "0.46.2",
4
4
  "description": "Node.js CLI tool for grabbing EPG from different sites",
5
5
  "homepage": "https://github.com/freearhey/epg-grabber",
6
6
  "preferGlobal": true,
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/freearhey/epg-grabber.git"
35
35
  },
36
36
  "engines": {
37
- "node": ">=22.12.0"
37
+ "node": ">=20.20.0"
38
38
  },
39
39
  "dependencies": {
40
40
  "@freearhey/core": "^0.14.0",
@@ -70,5 +70,8 @@
70
70
  "typescript": "^5.9.2",
71
71
  "typescript-eslint": "^8.44.1",
72
72
  "vitest": "^3.2.4"
73
+ },
74
+ "overrides": {
75
+ "esbuild": "0.23.1"
73
76
  }
74
77
  }
package/src/index.ts CHANGED
@@ -30,7 +30,7 @@ export class EPGGrabber {
30
30
  if (!(channel instanceof Channel))
31
31
  throw new Error('The first argument must be the "Channel" class')
32
32
 
33
- config = merge(defaultConfig, config, this.globalConfig)
33
+ config = merge({}, defaultConfig, config, this.globalConfig)
34
34
 
35
35
  if (typeof config.logo !== 'function') return null
36
36
 
@@ -59,7 +59,7 @@ export class EPGGrabber {
59
59
 
60
60
  const utcDate = getUTCDate(date)
61
61
 
62
- config = merge(defaultConfig, config, this.globalConfig)
62
+ config = merge({}, defaultConfig, config, this.globalConfig)
63
63
 
64
64
  if (!config.parser) throw new Error('Could not find parser() in the config file')
65
65
  if (!config.site) throw new Error("The required 'site' property is missing")
@@ -175,7 +175,7 @@ export class EPGGrabberMock extends EPGGrabber {
175
175
 
176
176
  const utcDate = getUTCDate(date)
177
177
 
178
- config = merge(defaultConfig, config, this.globalConfig)
178
+ config = merge({}, defaultConfig, config, this.globalConfig)
179
179
 
180
180
  if (!config.parser) throw new Error('Could not find parser() in the config file')
181
181
 
package/tests/cli.test.ts CHANGED
@@ -57,72 +57,21 @@ it('can load mini config', () => {
57
57
  }
58
58
  )
59
59
 
60
- expect(stdout).contains(`{
61
- "site": "example.com",
62
- "url": "http://example.com/20210319/1tv.json",
63
- "channels": [
60
+ expect(stdout).contains('"site": "example.com"')
61
+ expect(stdout).contains('"url": "http://example.com/20210319/1tv.json"')
62
+ expect(stdout).contains(`"channels": [
64
63
  "tests/__data__/input/example.channels.xml"
65
- ],
66
- "request": {
67
- "timeout": 1,
68
- "httpAgent": {
69
- "_events": {},
70
- "_eventsCount": 2,
71
- "options": {
72
- "noDelay": true,
73
- "path": null
74
- },
75
- "requests": {},
76
- "sockets": {},
77
- "freeSockets": {},
78
- "keepAliveMsecs": 1000,
79
- "keepAlive": false,
80
- "maxSockets": null,
81
- "maxFreeSockets": 256,
82
- "scheduling": "lifo",
83
- "maxTotalSockets": null,
84
- "totalSocketCount": 0,
85
- "shouldLookup": false,
86
- "proxy": {
64
+ ]`)
65
+ expect(stdout).contains('"timeout": 1')
66
+ expect(stdout).contains(`"proxy": {
87
67
  "host": "127.0.0.1",
88
68
  "port": 1086,
89
69
  "type": 5
90
- },
91
- "timeout": null,
92
- "socketOptions": null
93
- },
94
- "httpsAgent": {
95
- "_events": {},
96
- "_eventsCount": 2,
97
- "options": {
98
- "noDelay": true,
99
- "path": null
100
- },
101
- "requests": {},
102
- "sockets": {},
103
- "freeSockets": {},
104
- "keepAliveMsecs": 1000,
105
- "keepAlive": false,
106
- "maxSockets": null,
107
- "maxFreeSockets": 256,
108
- "scheduling": "lifo",
109
- "maxTotalSockets": null,
110
- "totalSocketCount": 0,
111
- "shouldLookup": false,
112
- "proxy": {
113
- "host": "127.0.0.1",
114
- "port": 1086,
115
- "type": 5
116
- },
117
- "timeout": null,
118
- "socketOptions": null
119
- }
120
- },
121
- "output": "tests/__data__/output/mini.guide.xml",
122
- "days": 3,
123
- "delay": 0,
124
- "debug": true
125
- }`)
70
+ }`)
71
+ expect(stdout).contains('"output": "tests/__data__/output/mini.guide.xml"')
72
+ expect(stdout).contains('"days": 3')
73
+ expect(stdout).contains('"delay": 0')
74
+ expect(stdout).contains('"debug": true')
126
75
  expect(stdout).contains("File 'tests/__data__/output/mini.guide.xml' successfully saved")
127
76
  expect(content('tests/__data__/output/mini.guide.xml')).toEqual(
128
77
  content('tests/__data__/expected/mini.guide.xml')
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" ?><tv date="20251028">
2
- <channel id="3TV.com"><display-name>3 TV</display-name><icon src="http://example.com/logos/1TV.png?x=шеллы&amp;sid=777"/><url>https://example2.com</url></channel>
3
- <channel id="4TV.com"><display-name>4 TV</display-name><icon src="http://example.com/logos/1TV.png?x=шеллы&amp;sid=777"/><url>https://example2.com</url></channel>
4
- <channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>
5
- <channel id="2TV.com"><display-name>2 TV</display-name><icon src="http://example.com/logos/1TV.png?x=шеллы&amp;sid=777"/><url>https://example.com</url></channel>
6
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="3TV.com"><title>Program1</title></programme>
7
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="3TV.com"><title>Program1</title></programme>
8
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="2TV.com"><title>Program1</title></programme>
9
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="2TV.com"><title>Program1</title></programme>
10
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
11
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
12
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="4TV.com"><title>Program1</title></programme>
13
- <programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="4TV.com"><title>Program1</title></programme>
14
- </tv>