epg-grabber 0.45.0 → 0.46.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/dist/cli.js +23 -31
- package/dist/{index-CHTSs3QX.js → index-Bnw63KMN.js} +8 -8
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/cli.ts +25 -32
- package/src/index.ts +8 -7
- package/tests/cli.test.ts +41 -150
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,
|
|
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';
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
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() *
|
|
195
|
+
const total = groupChannels.count() * days;
|
|
202
196
|
const utcDate = getUTCDate(process.env.CURR_DATE);
|
|
203
|
-
const dates = Array.from({ length:
|
|
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,
|
|
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 (
|
|
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.
|
|
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
|
|
|
@@ -725,13 +725,13 @@ class EPGGrabber {
|
|
|
725
725
|
globalConfig = {};
|
|
726
726
|
client;
|
|
727
727
|
constructor(config = {}) {
|
|
728
|
-
this.globalConfig =
|
|
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
|
-
|
|
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,
|
|
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-
|
|
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
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
|
-
|
|
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
|
|
143
|
-
const method = (request.method as AllowedMethods)
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
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() *
|
|
228
|
+
const total = groupChannels.count() * days
|
|
234
229
|
const utcDate = getUTCDate(process.env.CURR_DATE)
|
|
235
|
-
const dates = Array.from({ length:
|
|
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,
|
|
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 (
|
|
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 =
|
|
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
|
-
"
|
|
41
|
-
"
|
|
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(
|
|
@@ -65,83 +57,21 @@ it('can load mini config', () => {
|
|
|
65
57
|
}
|
|
66
58
|
)
|
|
67
59
|
|
|
68
|
-
expect(stdout).contains(
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"output": "tests/__data__/output/mini.guide.xml",
|
|
72
|
-
"channels": [
|
|
60
|
+
expect(stdout).contains('"site": "example.com"')
|
|
61
|
+
expect(stdout).contains('"url": "http://example.com/20210319/1tv.json"')
|
|
62
|
+
expect(stdout).contains(`"channels": [
|
|
73
63
|
"tests/__data__/input/example.channels.xml"
|
|
74
|
-
]
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
"maxContentLength": 5242880,
|
|
78
|
-
"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
|
-
"httpAgent": {
|
|
86
|
-
"_events": {},
|
|
87
|
-
"_eventsCount": 2,
|
|
88
|
-
"options": {
|
|
89
|
-
"noDelay": true,
|
|
90
|
-
"path": null
|
|
91
|
-
},
|
|
92
|
-
"requests": {},
|
|
93
|
-
"sockets": {},
|
|
94
|
-
"freeSockets": {},
|
|
95
|
-
"keepAliveMsecs": 1000,
|
|
96
|
-
"keepAlive": false,
|
|
97
|
-
"maxSockets": null,
|
|
98
|
-
"maxFreeSockets": 256,
|
|
99
|
-
"scheduling": "lifo",
|
|
100
|
-
"maxTotalSockets": null,
|
|
101
|
-
"totalSocketCount": 0,
|
|
102
|
-
"shouldLookup": false,
|
|
103
|
-
"proxy": {
|
|
64
|
+
]`)
|
|
65
|
+
expect(stdout).contains('"timeout": 1')
|
|
66
|
+
expect(stdout).contains(`"proxy": {
|
|
104
67
|
"host": "127.0.0.1",
|
|
105
68
|
"port": 1086,
|
|
106
69
|
"type": 5
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"_events": {},
|
|
113
|
-
"_eventsCount": 2,
|
|
114
|
-
"options": {
|
|
115
|
-
"noDelay": true,
|
|
116
|
-
"path": null
|
|
117
|
-
},
|
|
118
|
-
"requests": {},
|
|
119
|
-
"sockets": {},
|
|
120
|
-
"freeSockets": {},
|
|
121
|
-
"keepAliveMsecs": 1000,
|
|
122
|
-
"keepAlive": false,
|
|
123
|
-
"maxSockets": null,
|
|
124
|
-
"maxFreeSockets": 256,
|
|
125
|
-
"scheduling": "lifo",
|
|
126
|
-
"maxTotalSockets": null,
|
|
127
|
-
"totalSocketCount": 0,
|
|
128
|
-
"shouldLookup": false,
|
|
129
|
-
"proxy": {
|
|
130
|
-
"host": "127.0.0.1",
|
|
131
|
-
"port": 1086,
|
|
132
|
-
"type": 5
|
|
133
|
-
},
|
|
134
|
-
"timeout": null,
|
|
135
|
-
"socketOptions": null
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
"maxConnections": 1,
|
|
139
|
-
"curl": false,
|
|
140
|
-
"debug": true,
|
|
141
|
-
"gzip": false,
|
|
142
|
-
"site": "example.com",
|
|
143
|
-
"url": "http://example.com/20210319/1tv.json"
|
|
144
|
-
}`)
|
|
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')
|
|
145
75
|
expect(stdout).contains("File 'tests/__data__/output/mini.guide.xml' successfully saved")
|
|
146
76
|
expect(content('tests/__data__/output/mini.guide.xml')).toEqual(
|
|
147
77
|
content('tests/__data__/expected/mini.guide.xml')
|
|
@@ -164,29 +94,18 @@ it('can generate gzip version', () => {
|
|
|
164
94
|
)
|
|
165
95
|
|
|
166
96
|
expect(stdout).contains(`{
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"output": "tests/__data__/output/mini.guide.xml.gz",
|
|
97
|
+
"site": "example.com",
|
|
98
|
+
"url": "http://example.com/20210319/1tv.json",
|
|
170
99
|
"channels": [
|
|
171
100
|
"tests/__data__/input/example.channels.xml"
|
|
172
101
|
],
|
|
173
102
|
"request": {
|
|
174
|
-
"
|
|
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
|
-
}
|
|
103
|
+
"timeout": 1
|
|
183
104
|
},
|
|
184
|
-
"
|
|
185
|
-
"
|
|
105
|
+
"output": "tests/__data__/output/mini.guide.xml.gz",
|
|
106
|
+
"delay": 0,
|
|
186
107
|
"debug": true,
|
|
187
|
-
"gzip": true
|
|
188
|
-
"site": "example.com",
|
|
189
|
-
"url": "http://example.com/20210319/1tv.json"
|
|
108
|
+
"gzip": true
|
|
190
109
|
}`)
|
|
191
110
|
expect(stdout).contains("File 'tests/__data__/output/mini.guide.xml.gz' successfully saved")
|
|
192
111
|
expect(fs.readFileSync('tests/__data__/output/mini.guide.xml.gz')).toEqual(
|
|
@@ -209,29 +128,17 @@ it('can produce multiple outputs', () => {
|
|
|
209
128
|
)
|
|
210
129
|
|
|
211
130
|
expect(stdout).contains(`{
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"output": "tests/__data__/output/{lang}/{xmltv_id}.xml",
|
|
131
|
+
"site": "example.com",
|
|
132
|
+
"url": "http://example.com/20210319/1tv.json",
|
|
215
133
|
"channels": [
|
|
216
134
|
"tests/__data__/input/example.channels.xml"
|
|
217
135
|
],
|
|
218
136
|
"request": {
|
|
219
|
-
"
|
|
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
|
-
}
|
|
137
|
+
"timeout": 1
|
|
228
138
|
},
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"debug": true
|
|
232
|
-
"gzip": false,
|
|
233
|
-
"site": "example.com",
|
|
234
|
-
"url": "http://example.com/20210319/1tv.json"
|
|
139
|
+
"output": "tests/__data__/output/{lang}/{xmltv_id}.xml",
|
|
140
|
+
"delay": 0,
|
|
141
|
+
"debug": true
|
|
235
142
|
}`)
|
|
236
143
|
expect(stdout).contains("File 'tests/__data__/output/fr/1TV.com.xml' successfully saved")
|
|
237
144
|
expect(stdout).contains("File 'tests/__data__/output/undefined/2TV.com.xml' successfully saved")
|
|
@@ -252,31 +159,23 @@ it('can load multiple "*.channels.xml" files at once', () => {
|
|
|
252
159
|
)
|
|
253
160
|
|
|
254
161
|
expect(stdout).contains(`{
|
|
162
|
+
"site": "example.com",
|
|
255
163
|
"days": 2,
|
|
256
|
-
"delay": 0,
|
|
257
|
-
"output": "tests/__data__/output/wildcard.guide.xml",
|
|
258
164
|
"channels": [
|
|
259
165
|
"tests/__data__/input/example_3.channels.xml",
|
|
260
166
|
"tests/__data__/input/example_2.channels.xml"
|
|
261
167
|
],
|
|
168
|
+
"output": "tests/__data__/output/wildcard.guide.xml",
|
|
262
169
|
"request": {
|
|
263
170
|
"method": "POST",
|
|
264
|
-
"maxContentLength": 5242880,
|
|
265
|
-
"timeout": 1,
|
|
266
|
-
"withCredentials": true,
|
|
267
|
-
"responseType": "arraybuffer",
|
|
268
|
-
"cache": false,
|
|
269
171
|
"headers": {
|
|
270
|
-
"User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)",
|
|
271
172
|
"Content-Type": "application/json",
|
|
272
173
|
"Cookie": "abc=123"
|
|
273
|
-
}
|
|
174
|
+
},
|
|
175
|
+
"timeout": 1
|
|
274
176
|
},
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
"debug": true,
|
|
278
|
-
"gzip": false,
|
|
279
|
-
"site": "example.com"
|
|
177
|
+
"delay": 0,
|
|
178
|
+
"debug": true
|
|
280
179
|
}`)
|
|
281
180
|
expect(stdout).contains("File 'tests/__data__/output/wildcard.guide.xml' successfully saved")
|
|
282
181
|
expect(content('tests/__data__/output/wildcard.guide.xml')).toEqual(
|
|
@@ -293,31 +192,23 @@ it('can parse list of "*.channels.xml" from array', () => {
|
|
|
293
192
|
)
|
|
294
193
|
|
|
295
194
|
expect(stdout).contains(`{
|
|
195
|
+
"site": "example.com",
|
|
296
196
|
"days": 2,
|
|
297
|
-
"delay": 0,
|
|
298
|
-
"output": "tests/__data__/output/channels_array.guide.xml",
|
|
299
197
|
"channels": [
|
|
300
198
|
"example_2.channels.xml",
|
|
301
199
|
"example_3.channels.xml"
|
|
302
200
|
],
|
|
201
|
+
"output": "tests/__data__/output/channels_array.guide.xml",
|
|
303
202
|
"request": {
|
|
304
203
|
"method": "POST",
|
|
305
|
-
"maxContentLength": 5242880,
|
|
306
|
-
"timeout": 1,
|
|
307
|
-
"withCredentials": true,
|
|
308
|
-
"responseType": "arraybuffer",
|
|
309
|
-
"cache": false,
|
|
310
204
|
"headers": {
|
|
311
|
-
"User-Agent": "EPGGrabber/0.44.0 (https://github.com/freearhey/epg-grabber)",
|
|
312
205
|
"Content-Type": "application/json",
|
|
313
206
|
"Cookie": "abc=123"
|
|
314
|
-
}
|
|
207
|
+
},
|
|
208
|
+
"timeout": 1
|
|
315
209
|
},
|
|
316
|
-
"
|
|
317
|
-
"
|
|
318
|
-
"debug": true,
|
|
319
|
-
"gzip": false,
|
|
320
|
-
"site": "example.com"
|
|
210
|
+
"delay": 0,
|
|
211
|
+
"debug": true
|
|
321
212
|
}`)
|
|
322
213
|
expect(stdout).contains(
|
|
323
214
|
"File 'tests/__data__/output/channels_array.guide.xml' successfully saved"
|