epg-grabber 0.45.0 → 0.46.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/dist/cli.js CHANGED
@@ -1,12 +1,11 @@
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, i as isObject, g as getAbsPath, c as getUTCDate } from './index-CHTSs3QX.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-DUJ5SdIU.js';
3
3
  import { Collection, Template } from '@freearhey/core';
4
4
  import { Command, Option } from 'commander';
5
5
  import { SocksProxyAgent } from 'socks-proxy-agent';
6
6
  import { CurlGenerator } from 'curl-generator';
7
7
  import winston from 'winston';
8
8
  import path from 'path';
9
- import { AxiosHeaders } from 'axios';
10
9
  import { TaskQueue } from 'cwait';
11
10
  import merge from 'lodash.merge';
12
11
  import Promise$1 from 'bluebird';
@@ -19,6 +18,7 @@ import 'dayjs';
19
18
  import 'node:url';
20
19
  import 'axios-mock-adapter';
21
20
  import 'lodash.padstart';
21
+ import 'axios';
22
22
  import 'axios-cache-interceptor';
23
23
  import 'xml-js';
24
24
 
@@ -121,22 +121,19 @@ async function main() {
121
121
  if (typeof options.debug === "boolean") config.debug = options.debug;
122
122
  if (typeof options.curl === "boolean") config.curl = options.curl;
123
123
  if (typeof options.gzip === "boolean") config.gzip = options.gzip;
124
+ logger.debug(`Config: ${JSON.stringify(config, null, 2)}`);
124
125
  const grabber = process.env.NODE_ENV === "test" ? new EPGGrabberMock(config) : new EPGGrabber(config);
125
- const globalConfig = grabber.globalConfig;
126
- logger.debug(`Config: ${JSON.stringify(globalConfig, null, 2)}`);
127
126
  grabber.client.instance.interceptors.request.use(
128
127
  (request) => {
129
128
  logger.debug(`Request: ${JSON.stringify(request, null, 2)}`);
130
- if (globalConfig.curl) {
131
- const headers = request.headers instanceof AxiosHeaders ? request.headers : {};
132
- const method = request.method || "GET";
133
- const curl = CurlGenerator({
134
- url: request.url || "",
135
- method,
136
- headers,
137
- body: request.data
138
- });
139
- logger.info(curl);
129
+ const curl = config.curl || defaultConfig.curl;
130
+ if (curl) {
131
+ const url = request.url || "";
132
+ const method = request.method ? request.method : "GET";
133
+ const headers = request.headers ? request.headers.toJSON() : void 0;
134
+ const body = request.data ? request.data : void 0;
135
+ const curl2 = CurlGenerator({ url, method, headers, body });
136
+ logger.info(curl2);
140
137
  }
141
138
  return request;
142
139
  },
@@ -160,11 +157,11 @@ async function main() {
160
157
  },
161
158
  (error) => Promise$1.reject(error)
162
159
  );
163
- if (!Array.isArray(globalConfig.channels) || !globalConfig.channels.length)
160
+ if (!Array.isArray(config.channels) || !config.channels.length)
164
161
  throw new Error('Path to "*.channels.xml" is missing');
165
162
  const channels = new Collection();
166
163
  const rootDir = options.channels ? process.cwd() : path$1.dirname(options.config);
167
- globalConfig.channels.forEach((filepath) => {
164
+ config.channels.forEach((filepath) => {
168
165
  const absFilepath = getAbsPath(filepath, rootDir);
169
166
  logger.debug(`Loading "${absFilepath}"...`);
170
167
  const channelsXML = fs.readFileSync(absFilepath, "utf8");
@@ -172,9 +169,12 @@ async function main() {
172
169
  channels.concat(new Collection(channelsFromXML));
173
170
  });
174
171
  if (channels.isEmpty()) throw new Error("No channels found");
175
- if (typeof globalConfig.output !== "string")
176
- throw new Error('The "output" property should return the string');
177
- const template = new Template(globalConfig.output);
172
+ const days = config.days || defaultConfig.days;
173
+ const maxConnections = config.maxConnections || defaultConfig.maxConnections;
174
+ const gzip = config.gzip || defaultConfig.gzip;
175
+ const defaultOutput = gzip ? defaultConfig.output + ".gz" : defaultConfig.output;
176
+ const output = config.output || defaultOutput;
177
+ const template = new Template(output);
178
178
  const variables = template.variables();
179
179
  const groups = channels.groupBy((channel) => {
180
180
  let groupId = "";
@@ -187,27 +187,21 @@ async function main() {
187
187
  return groupId;
188
188
  });
189
189
  logger.info("Processing...");
190
- if (typeof globalConfig.days !== "number")
191
- throw new Error('The "days" property should return the number');
192
- if (typeof globalConfig.maxConnections !== "number")
193
- throw new Error('The "maxConnections" property should return the number');
194
- if (typeof globalConfig.gzip !== "boolean")
195
- throw new Error('The "gzip" property should return the boolean');
196
190
  for (const groupId of groups.keys()) {
197
191
  const group = groups.get(groupId);
198
192
  const groupChannels = new Collection(group);
199
193
  let programs = new Collection();
200
194
  let index = 1;
201
- const total = groupChannels.count() * globalConfig.days;
195
+ const total = groupChannels.count() * days;
202
196
  const utcDate = getUTCDate(process.env.CURR_DATE);
203
- const dates = Array.from({ length: globalConfig.days }, (_, i) => utcDate.add(i, "d"));
197
+ const dates = Array.from({ length: days }, (_, i) => utcDate.add(i, "d"));
204
198
  let queue = new Collection();
205
199
  groupChannels.forEach((channel) => {
206
200
  for (let date of dates) {
207
201
  queue.add({ channel, date });
208
202
  }
209
203
  });
210
- const taskQueue = new TaskQueue(Promise$1, globalConfig.maxConnections);
204
+ const taskQueue = new TaskQueue(Promise$1, maxConnections);
211
205
  const requests = queue.map(
212
206
  taskQueue.wrap(async (queueItem) => {
213
207
  const { channel, date } = queueItem;
@@ -231,12 +225,10 @@ async function main() {
231
225
  let outputPath = template.format(channelSample.toObject());
232
226
  const outputDir = path$1.dirname(outputPath);
233
227
  fs.mkdirSync(outputDir, { recursive: true });
234
- if (globalConfig.gzip) {
228
+ if (gzip) {
235
229
  const compressed = pako.gzip(xml);
236
- outputPath = outputPath || "guide.xml.gz";
237
230
  fs.writeFileSync(outputPath, compressed);
238
231
  } else {
239
- outputPath = outputPath || "guide.xml";
240
232
  fs.writeFileSync(outputPath, xml);
241
233
  }
242
234
  logger.info(`File '${outputPath}' successfully saved`);
@@ -102,7 +102,7 @@ function toArray(value) {
102
102
  }
103
103
 
104
104
  var name = "epg-grabber";
105
- var version = "0.45.0";
105
+ var version = "0.46.0";
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
 
@@ -725,13 +725,13 @@ class EPGGrabber {
725
725
  globalConfig = {};
726
726
  client;
727
727
  constructor(config = {}) {
728
- this.globalConfig = merge(defaultConfig, config);
728
+ this.globalConfig = config;
729
729
  this.client = new Client();
730
730
  }
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(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,8 +749,7 @@ class EPGGrabber {
749
749
  config = {};
750
750
  }
751
751
  const utcDate = getUTCDate(date);
752
- const requestContext = { channel, date: utcDate, config };
753
- config = merge(config, this.globalConfig);
752
+ config = merge(defaultConfig, config, this.globalConfig);
754
753
  if (!config.parser) throw new Error("Could not find parser() in the config file");
755
754
  if (!config.site) throw new Error("The required 'site' property is missing");
756
755
  if (!config.url) throw new Error("The required 'url' property is missing");
@@ -763,6 +762,7 @@ class EPGGrabber {
763
762
  throw new Error("The 'logo' property should return the function");
764
763
  try {
765
764
  if (typeof config.delay === "number") await sleep(config.delay);
765
+ const requestContext = { channel, date: utcDate, config };
766
766
  const request = await Client.buildRequest(requestContext);
767
767
  const response = await this.client.sendRequest(request);
768
768
  const parserContext = {
@@ -826,10 +826,10 @@ class EPGGrabberMock extends EPGGrabber {
826
826
  config = {};
827
827
  }
828
828
  const utcDate = getUTCDate(date);
829
- config = merge(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
- const requestContext = { channel, date: utcDate, config };
832
831
  try {
832
+ const requestContext = { channel, date: utcDate, config };
833
833
  const request = await Client.buildRequest(requestContext);
834
834
  const mock = new AxiosMockAdapter(this.client.instance);
835
835
  mock.onAny().reply(200, Buffer.from(JSON.stringify([]), "utf8"));
@@ -854,4 +854,4 @@ class EPGGrabberMock extends EPGGrabber {
854
854
  }
855
855
  }
856
856
 
857
- export { Channel as C, EPGGrabberMock as E, Program as P, parseProxy as a, EPGGrabber as b, getUTCDate as c, description as d, getAbsPath as g, isObject as i, loadJs as l, name as n, parseNumber as p, version as v };
857
+ export { Channel as C, EPGGrabberMock as E, Program as P, parseProxy as a, EPGGrabber as b, defaultConfig as c, description as d, getUTCDate as e, getAbsPath as g, isObject as i, loadJs as l, name as n, parseNumber as p, version as v };
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-CHTSs3QX.js';
2
+ export { C as Channel, b as EPGGrabber, E as EPGGrabberMock, P as Program } from './index-DUJ5SdIU.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.45.0",
3
+ "version": "0.46.0",
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,
package/src/cli.ts CHANGED
@@ -8,6 +8,7 @@ import { Command, OptionValues, Option } from 'commander'
8
8
  import { EPGGrabber, EPGGrabberMock } from './index'
9
9
  import { SocksProxyAgent } from 'socks-proxy-agent'
10
10
  import { CurlGenerator } from 'curl-generator'
11
+ import defaultConfig from './default.config'
11
12
  import { Program, Channel } from './models'
12
13
  import { Logger } from './core/logger'
13
14
  import { SiteConfig } from './types'
@@ -116,17 +117,17 @@ async function main() {
116
117
  if (typeof options.curl === 'boolean') config.curl = options.curl
117
118
  if (typeof options.gzip === 'boolean') config.gzip = options.gzip
118
119
 
120
+ logger.debug(`Config: ${JSON.stringify(config, null, 2)}`)
121
+
119
122
  const grabber =
120
123
  process.env.NODE_ENV === 'test' ? new EPGGrabberMock(config) : new EPGGrabber(config)
121
124
 
122
- const globalConfig = grabber.globalConfig
123
-
124
- logger.debug(`Config: ${JSON.stringify(globalConfig, null, 2)}`)
125
-
126
125
  grabber.client.instance.interceptors.request.use(
127
126
  request => {
128
127
  logger.debug(`Request: ${JSON.stringify(request, null, 2)}`)
129
- if (globalConfig.curl) {
128
+
129
+ const curl = config.curl || defaultConfig.curl
130
+ if (curl) {
130
131
  type AllowedMethods =
131
132
  | 'GET'
132
133
  | 'get'
@@ -139,15 +140,14 @@ async function main() {
139
140
  | 'DELETE'
140
141
  | 'delete'
141
142
 
142
- const headers = request.headers instanceof AxiosHeaders ? request.headers : {}
143
- const method = (request.method as AllowedMethods) || 'GET'
143
+ const url = request.url || ''
144
+ const method = request.method ? (request.method as AllowedMethods) : 'GET'
145
+ const headers = request.headers
146
+ ? (request.headers.toJSON() as Record<string, string>)
147
+ : undefined
148
+ const body = request.data ? (request.data as CurlBody) : undefined
144
149
 
145
- const curl = CurlGenerator({
146
- url: request.url || '',
147
- method,
148
- headers,
149
- body: request.data as CurlBody
150
- })
150
+ const curl = CurlGenerator({ url, method, headers, body })
151
151
 
152
152
  logger.info(curl)
153
153
  }
@@ -182,12 +182,12 @@ async function main() {
182
182
  error => Promise.reject(error)
183
183
  )
184
184
 
185
- if (!Array.isArray(globalConfig.channels) || !globalConfig.channels.length)
185
+ if (!Array.isArray(config.channels) || !config.channels.length)
186
186
  throw new Error('Path to "*.channels.xml" is missing')
187
187
 
188
188
  const channels = new Collection<Channel>()
189
189
  const rootDir = options.channels ? process.cwd() : path.dirname(options.config)
190
- globalConfig.channels.forEach((filepath: string) => {
190
+ config.channels.forEach((filepath: string) => {
191
191
  const absFilepath = getAbsPath(filepath, rootDir)
192
192
 
193
193
  logger.debug(`Loading "${absFilepath}"...`)
@@ -199,10 +199,12 @@ async function main() {
199
199
 
200
200
  if (channels.isEmpty()) throw new Error('No channels found')
201
201
 
202
- if (typeof globalConfig.output !== 'string')
203
- throw new Error('The "output" property should return the string')
204
-
205
- const template = new Template(globalConfig.output)
202
+ const days = config.days || defaultConfig.days
203
+ const maxConnections = config.maxConnections || defaultConfig.maxConnections
204
+ const gzip = config.gzip || defaultConfig.gzip
205
+ const defaultOutput = gzip ? defaultConfig.output + '.gz' : defaultConfig.output
206
+ const output = config.output || defaultOutput
207
+ const template = new Template(output)
206
208
  const variables = template.variables()
207
209
  const groups: Dictionary<Channel[]> = channels.groupBy((channel: Channel) => {
208
210
  let groupId = ''
@@ -217,22 +219,15 @@ async function main() {
217
219
  })
218
220
 
219
221
  logger.info('Processing...')
220
- if (typeof globalConfig.days !== 'number')
221
- throw new Error('The "days" property should return the number')
222
- if (typeof globalConfig.maxConnections !== 'number')
223
- throw new Error('The "maxConnections" property should return the number')
224
- if (typeof globalConfig.gzip !== 'boolean')
225
- throw new Error('The "gzip" property should return the boolean')
226
-
227
222
  for (const groupId of groups.keys()) {
228
223
  const group = groups.get(groupId)
229
224
  const groupChannels = new Collection<Channel>(group)
230
225
  let programs = new Collection<Program>()
231
226
  let index = 1
232
227
 
233
- const total = groupChannels.count() * globalConfig.days
228
+ const total = groupChannels.count() * days
234
229
  const utcDate = getUTCDate(process.env.CURR_DATE)
235
- const dates = Array.from({ length: globalConfig.days }, (_, i) => utcDate.add(i, 'd'))
230
+ const dates = Array.from({ length: days }, (_, i) => utcDate.add(i, 'd'))
236
231
 
237
232
  let queue = new Collection<QueueItem>()
238
233
  groupChannels.forEach((channel: Channel) => {
@@ -241,7 +236,7 @@ async function main() {
241
236
  }
242
237
  })
243
238
 
244
- const taskQueue = new TaskQueue(Promise, globalConfig.maxConnections)
239
+ const taskQueue = new TaskQueue(Promise, maxConnections)
245
240
  const requests = queue.map(
246
241
  taskQueue.wrap(async (queueItem: QueueItem) => {
247
242
  const { channel, date } = queueItem
@@ -277,12 +272,10 @@ async function main() {
277
272
 
278
273
  fs.mkdirSync(outputDir, { recursive: true })
279
274
 
280
- if (globalConfig.gzip) {
275
+ if (gzip) {
281
276
  const compressed = pako.gzip(xml)
282
- outputPath = outputPath || 'guide.xml.gz'
283
277
  fs.writeFileSync(outputPath, compressed)
284
278
  } else {
285
- outputPath = outputPath || 'guide.xml'
286
279
  fs.writeFileSync(outputPath, xml)
287
280
  }
288
281
 
package/src/index.ts CHANGED
@@ -18,7 +18,7 @@ export class EPGGrabber {
18
18
  client: Client
19
19
 
20
20
  constructor(config: SiteConfig = {}) {
21
- this.globalConfig = merge(defaultConfig, config)
21
+ this.globalConfig = config
22
22
  this.client = new Client()
23
23
  }
24
24
 
@@ -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(config, this.globalConfig)
33
+ config = merge(defaultConfig, config, this.globalConfig)
34
34
 
35
35
  if (typeof config.logo !== 'function') return null
36
36
 
@@ -58,9 +58,8 @@ export class EPGGrabber {
58
58
  }
59
59
 
60
60
  const utcDate = getUTCDate(date)
61
- const requestContext = { channel, date: utcDate, config }
62
61
 
63
- config = merge(config, this.globalConfig)
62
+ config = merge(defaultConfig, config, this.globalConfig)
64
63
 
65
64
  if (!config.parser) throw new Error('Could not find parser() in the config file')
66
65
  if (!config.site) throw new Error("The required 'site' property is missing")
@@ -76,6 +75,8 @@ export class EPGGrabber {
76
75
  try {
77
76
  if (typeof config.delay === 'number') await sleep(config.delay)
78
77
 
78
+ const requestContext = { channel, date: utcDate, config }
79
+
79
80
  const request = await Client.buildRequest(requestContext)
80
81
 
81
82
  const response = await this.client.sendRequest(request)
@@ -174,13 +175,13 @@ export class EPGGrabberMock extends EPGGrabber {
174
175
 
175
176
  const utcDate = getUTCDate(date)
176
177
 
177
- config = merge(config, this.globalConfig)
178
+ config = merge(defaultConfig, config, this.globalConfig)
178
179
 
179
180
  if (!config.parser) throw new Error('Could not find parser() in the config file')
180
181
 
181
- const requestContext = { channel, date: utcDate, config }
182
-
183
182
  try {
183
+ const requestContext = { channel, date: utcDate, config }
184
+
184
185
  const request = await Client.buildRequest(requestContext)
185
186
 
186
187
  const mock = new AxiosMockAdapter(this.client.instance)
package/tests/cli.test.ts CHANGED
@@ -18,30 +18,22 @@ it('can load config', () => {
18
18
  )
19
19
 
20
20
  expect(stdout).contains(`{
21
+ "site": "example.com",
21
22
  "days": 2,
22
- "delay": 0,
23
- "output": "tests/__data__/output/example.guide.xml",
24
23
  "channels": [
25
24
  "example.channels.xml"
26
25
  ],
26
+ "output": "tests/__data__/output/example.guide.xml",
27
27
  "request": {
28
28
  "method": "POST",
29
- "maxContentLength": 5242880,
30
- "timeout": 1,
31
- "withCredentials": true,
32
- "responseType": "arraybuffer",
33
- "cache": false,
34
29
  "headers": {
35
- "User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)",
36
30
  "Content-Type": "application/json",
37
31
  "Cookie": "abc=123"
38
- }
32
+ },
33
+ "timeout": 1
39
34
  },
40
- "maxConnections": 1,
41
- "curl": false,
42
- "debug": true,
43
- "gzip": false,
44
- "site": "example.com"
35
+ "delay": 0,
36
+ "debug": true
45
37
  }`)
46
38
  expect(stdout).contains("File 'tests/__data__/output/example.guide.xml' successfully saved")
47
39
  expect(content('tests/__data__/output/example.guide.xml')).toEqual(
@@ -66,22 +58,13 @@ it('can load mini config', () => {
66
58
  )
67
59
 
68
60
  expect(stdout).contains(`{
69
- "days": 3,
70
- "delay": 0,
71
- "output": "tests/__data__/output/mini.guide.xml",
61
+ "site": "example.com",
62
+ "url": "http://example.com/20210319/1tv.json",
72
63
  "channels": [
73
64
  "tests/__data__/input/example.channels.xml"
74
65
  ],
75
66
  "request": {
76
- "method": "GET",
77
- "maxContentLength": 5242880,
78
67
  "timeout": 1,
79
- "withCredentials": true,
80
- "responseType": "arraybuffer",
81
- "cache": false,
82
- "headers": {
83
- "User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)"
84
- },
85
68
  "httpAgent": {
86
69
  "_events": {},
87
70
  "_eventsCount": 2,
@@ -135,12 +118,10 @@ it('can load mini config', () => {
135
118
  "socketOptions": null
136
119
  }
137
120
  },
138
- "maxConnections": 1,
139
- "curl": false,
140
- "debug": true,
141
- "gzip": false,
142
- "site": "example.com",
143
- "url": "http://example.com/20210319/1tv.json"
121
+ "output": "tests/__data__/output/mini.guide.xml",
122
+ "days": 3,
123
+ "delay": 0,
124
+ "debug": true
144
125
  }`)
145
126
  expect(stdout).contains("File 'tests/__data__/output/mini.guide.xml' successfully saved")
146
127
  expect(content('tests/__data__/output/mini.guide.xml')).toEqual(
@@ -164,29 +145,18 @@ it('can generate gzip version', () => {
164
145
  )
165
146
 
166
147
  expect(stdout).contains(`{
167
- "days": 1,
168
- "delay": 0,
169
- "output": "tests/__data__/output/mini.guide.xml.gz",
148
+ "site": "example.com",
149
+ "url": "http://example.com/20210319/1tv.json",
170
150
  "channels": [
171
151
  "tests/__data__/input/example.channels.xml"
172
152
  ],
173
153
  "request": {
174
- "method": "GET",
175
- "maxContentLength": 5242880,
176
- "timeout": 1,
177
- "withCredentials": true,
178
- "responseType": "arraybuffer",
179
- "cache": false,
180
- "headers": {
181
- "User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)"
182
- }
154
+ "timeout": 1
183
155
  },
184
- "maxConnections": 1,
185
- "curl": false,
156
+ "output": "tests/__data__/output/mini.guide.xml.gz",
157
+ "delay": 0,
186
158
  "debug": true,
187
- "gzip": true,
188
- "site": "example.com",
189
- "url": "http://example.com/20210319/1tv.json"
159
+ "gzip": true
190
160
  }`)
191
161
  expect(stdout).contains("File 'tests/__data__/output/mini.guide.xml.gz' successfully saved")
192
162
  expect(fs.readFileSync('tests/__data__/output/mini.guide.xml.gz')).toEqual(
@@ -209,29 +179,17 @@ it('can produce multiple outputs', () => {
209
179
  )
210
180
 
211
181
  expect(stdout).contains(`{
212
- "days": 1,
213
- "delay": 0,
214
- "output": "tests/__data__/output/{lang}/{xmltv_id}.xml",
182
+ "site": "example.com",
183
+ "url": "http://example.com/20210319/1tv.json",
215
184
  "channels": [
216
185
  "tests/__data__/input/example.channels.xml"
217
186
  ],
218
187
  "request": {
219
- "method": "GET",
220
- "maxContentLength": 5242880,
221
- "timeout": 1,
222
- "withCredentials": true,
223
- "responseType": "arraybuffer",
224
- "cache": false,
225
- "headers": {
226
- "User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)"
227
- }
188
+ "timeout": 1
228
189
  },
229
- "maxConnections": 1,
230
- "curl": false,
231
- "debug": true,
232
- "gzip": false,
233
- "site": "example.com",
234
- "url": "http://example.com/20210319/1tv.json"
190
+ "output": "tests/__data__/output/{lang}/{xmltv_id}.xml",
191
+ "delay": 0,
192
+ "debug": true
235
193
  }`)
236
194
  expect(stdout).contains("File 'tests/__data__/output/fr/1TV.com.xml' successfully saved")
237
195
  expect(stdout).contains("File 'tests/__data__/output/undefined/2TV.com.xml' successfully saved")
@@ -252,31 +210,23 @@ it('can load multiple "*.channels.xml" files at once', () => {
252
210
  )
253
211
 
254
212
  expect(stdout).contains(`{
213
+ "site": "example.com",
255
214
  "days": 2,
256
- "delay": 0,
257
- "output": "tests/__data__/output/wildcard.guide.xml",
258
215
  "channels": [
259
216
  "tests/__data__/input/example_3.channels.xml",
260
217
  "tests/__data__/input/example_2.channels.xml"
261
218
  ],
219
+ "output": "tests/__data__/output/wildcard.guide.xml",
262
220
  "request": {
263
221
  "method": "POST",
264
- "maxContentLength": 5242880,
265
- "timeout": 1,
266
- "withCredentials": true,
267
- "responseType": "arraybuffer",
268
- "cache": false,
269
222
  "headers": {
270
- "User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)",
271
223
  "Content-Type": "application/json",
272
224
  "Cookie": "abc=123"
273
- }
225
+ },
226
+ "timeout": 1
274
227
  },
275
- "maxConnections": 1,
276
- "curl": false,
277
- "debug": true,
278
- "gzip": false,
279
- "site": "example.com"
228
+ "delay": 0,
229
+ "debug": true
280
230
  }`)
281
231
  expect(stdout).contains("File 'tests/__data__/output/wildcard.guide.xml' successfully saved")
282
232
  expect(content('tests/__data__/output/wildcard.guide.xml')).toEqual(
@@ -293,31 +243,23 @@ it('can parse list of "*.channels.xml" from array', () => {
293
243
  )
294
244
 
295
245
  expect(stdout).contains(`{
246
+ "site": "example.com",
296
247
  "days": 2,
297
- "delay": 0,
298
- "output": "tests/__data__/output/channels_array.guide.xml",
299
248
  "channels": [
300
249
  "example_2.channels.xml",
301
250
  "example_3.channels.xml"
302
251
  ],
252
+ "output": "tests/__data__/output/channels_array.guide.xml",
303
253
  "request": {
304
254
  "method": "POST",
305
- "maxContentLength": 5242880,
306
- "timeout": 1,
307
- "withCredentials": true,
308
- "responseType": "arraybuffer",
309
- "cache": false,
310
255
  "headers": {
311
- "User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)",
312
256
  "Content-Type": "application/json",
313
257
  "Cookie": "abc=123"
314
- }
258
+ },
259
+ "timeout": 1
315
260
  },
316
- "maxConnections": 1,
317
- "curl": false,
318
- "debug": true,
319
- "gzip": false,
320
- "site": "example.com"
261
+ "delay": 0,
262
+ "debug": true
321
263
  }`)
322
264
  expect(stdout).contains(
323
265
  "File 'tests/__data__/output/channels_array.guide.xml' successfully saved"