epg-grabber 0.40.3 → 0.41.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/package.json +17 -20
- package/src/client.js +5 -10
- package/src/file.js +2 -6
- package/src/utils.js +9 -5
- package/tests/__data__/output/guide.xml +10 -0
- package/tests/index.test.js +0 -29
- package/tests/__data__/output/duplicates.guide.xml +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epg-grabber",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Node.js CLI tool for grabbing EPG from different sites",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -30,33 +30,30 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"axios": "^1.6.1",
|
|
33
|
-
"axios-cache-interceptor": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"curl-generator": "^0.2.0",
|
|
33
|
+
"axios-cache-interceptor": "^1.8.0",
|
|
34
|
+
"commander": "^14.0.0",
|
|
35
|
+
"curl-generator": "^0.4.2",
|
|
37
36
|
"cwait": "^1.1.2",
|
|
38
|
-
"dayjs": "^1.
|
|
39
|
-
"epg-parser": "^0.1
|
|
40
|
-
"fs-extra": "^11.
|
|
41
|
-
"glob": "^
|
|
42
|
-
"http-cookie-agent": "^6.0.8",
|
|
37
|
+
"dayjs": "^1.11.13",
|
|
38
|
+
"epg-parser": "^0.3.1",
|
|
39
|
+
"fs-extra": "^11.3.0",
|
|
40
|
+
"glob": "^11.0.3",
|
|
43
41
|
"lodash": "^4.17.21",
|
|
44
42
|
"node-gzip": "^1.1.2",
|
|
45
43
|
"socks-proxy-agent": "^8.0.5",
|
|
46
|
-
"
|
|
47
|
-
"winston": "^3.3.3",
|
|
44
|
+
"winston": "^3.17.0",
|
|
48
45
|
"xml-js": "^1.6.11"
|
|
49
46
|
},
|
|
50
47
|
"devDependencies": {
|
|
51
48
|
"@babel/core": "^7.13.14",
|
|
52
|
-
"@babel/preset-env": "^7.
|
|
53
|
-
"@eslint/eslintrc": "^3.
|
|
54
|
-
"@eslint/js": "^9.
|
|
55
|
-
"babel-jest": "^
|
|
56
|
-
"eslint": "^9.
|
|
57
|
-
"globals": "^
|
|
58
|
-
"jest": "^
|
|
59
|
-
"jest-mock-axios": "^4.
|
|
49
|
+
"@babel/preset-env": "^7.28.0",
|
|
50
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
51
|
+
"@eslint/js": "^9.31.0",
|
|
52
|
+
"babel-jest": "^30.0.4",
|
|
53
|
+
"eslint": "^9.31.0",
|
|
54
|
+
"globals": "^16.3.0",
|
|
55
|
+
"jest": "^30.0.4",
|
|
56
|
+
"jest-mock-axios": "^4.5.0"
|
|
60
57
|
},
|
|
61
58
|
"jest": {
|
|
62
59
|
"testEnvironment": "node"
|
package/src/client.js
CHANGED
|
@@ -7,8 +7,6 @@ module.exports.create = create
|
|
|
7
7
|
module.exports.buildRequest = buildRequest
|
|
8
8
|
module.exports.parseResponse = parseResponse
|
|
9
9
|
|
|
10
|
-
let timeout
|
|
11
|
-
|
|
12
10
|
function create(config) {
|
|
13
11
|
const client = axios.defaults.cache
|
|
14
12
|
? axios
|
|
@@ -51,11 +49,13 @@ function create(config) {
|
|
|
51
49
|
)
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
clearTimeout(timeout)
|
|
55
52
|
return response
|
|
56
53
|
},
|
|
57
54
|
function (error) {
|
|
58
|
-
|
|
55
|
+
if (error.name === 'CanceledError') {
|
|
56
|
+
error.message = 'Connection timeout'
|
|
57
|
+
return Promise.reject(error)
|
|
58
|
+
}
|
|
59
59
|
return Promise.reject(error)
|
|
60
60
|
}
|
|
61
61
|
)
|
|
@@ -64,16 +64,11 @@ function create(config) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
async function buildRequest({ channel, date, config }) {
|
|
67
|
-
const CancelToken = axios.CancelToken
|
|
68
|
-
const source = CancelToken.source()
|
|
69
67
|
const request = { ...config.request }
|
|
70
|
-
timeout = setTimeout(() => {
|
|
71
|
-
source.cancel('Connection timeout')
|
|
72
|
-
}, request.timeout)
|
|
73
68
|
request.headers = await getRequestHeaders({ channel, date, config })
|
|
74
69
|
request.url = await getRequestUrl({ channel, date, config })
|
|
75
70
|
request.data = await getRequestData({ channel, date, config })
|
|
76
|
-
request.
|
|
71
|
+
request.signal = AbortSignal.timeout(request.timeout)
|
|
77
72
|
|
|
78
73
|
if (config.curl) {
|
|
79
74
|
const curl = CurlGenerator({
|
package/src/file.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
-
const glob = require('glob')
|
|
3
|
+
const { glob } = require('glob')
|
|
4
4
|
|
|
5
5
|
module.exports.list = list
|
|
6
6
|
module.exports.read = read
|
|
@@ -12,11 +12,7 @@ module.exports.templateVariables = templateVariables
|
|
|
12
12
|
module.exports.templateFormat = templateFormat
|
|
13
13
|
|
|
14
14
|
function list(pattern) {
|
|
15
|
-
return
|
|
16
|
-
glob(pattern, function (err, files) {
|
|
17
|
-
resolve(files)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
15
|
+
return glob(pattern)
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
function read(filepath) {
|
package/src/utils.js
CHANGED
|
@@ -19,15 +19,19 @@ module.exports.parseProxy = parseProxy
|
|
|
19
19
|
function parseProxy(_url) {
|
|
20
20
|
const parsed = new URL(_url)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const result = {
|
|
23
23
|
protocol: parsed.protocol.replace(':', '') || null,
|
|
24
|
-
auth: {
|
|
25
|
-
username: parsed.username || null,
|
|
26
|
-
password: parsed.password || null
|
|
27
|
-
},
|
|
28
24
|
host: parsed.hostname,
|
|
29
25
|
port: parsed.port ? parseInt(parsed.port) : null
|
|
30
26
|
}
|
|
27
|
+
|
|
28
|
+
if (parsed.username || parsed.password) {
|
|
29
|
+
result.auth = {}
|
|
30
|
+
if (parsed.username) result.auth.username = parsed.username
|
|
31
|
+
if (parsed.password) result.auth.password = parsed.password
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return result
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
function sleep(ms) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?><tv date="20250718">
|
|
2
|
+
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url><lcn>36</lcn></channel>
|
|
3
|
+
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
|
+
<channel id="3TV.com"><display-name>3 TV</display-name><url>https://example2.com</url></channel>
|
|
5
|
+
<channel id="4TV.com"><display-name>4 TV</display-name><url>https://example2.com</url></channel>
|
|
6
|
+
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
|
|
7
|
+
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="4TV.com"><title>Program1</title></programme>
|
|
8
|
+
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="3TV.com"><title>Program1</title></programme>
|
|
9
|
+
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="2TV.com"><title>Program1</title></programme>
|
|
10
|
+
</tv>
|
package/tests/index.test.js
CHANGED
|
@@ -7,35 +7,6 @@ import axios from 'axios'
|
|
|
7
7
|
|
|
8
8
|
jest.mock('axios')
|
|
9
9
|
|
|
10
|
-
it('return "Connection timeout" error if server does not response', done => {
|
|
11
|
-
const config = {
|
|
12
|
-
site: 'example.com',
|
|
13
|
-
request: {
|
|
14
|
-
timeout: 1000
|
|
15
|
-
},
|
|
16
|
-
url({ date, channel }) {
|
|
17
|
-
return `https://www.cosmote.gr/cosmotetv/residential/program/epg/programchannel?p_p_id=channelprogram_WAR_OTETVportlet&p_p_lifecycle=0&_channelprogram_WAR_OTETVportlet_platform=IPTV&_channelprogram_WAR_OTETVportlet_date=${date.format(
|
|
18
|
-
'DD-MM-YYYY'
|
|
19
|
-
)}&_channelprogram_WAR_OTETVportlet_articleTitleUrl=${channel.site_id}`
|
|
20
|
-
},
|
|
21
|
-
parser: () => []
|
|
22
|
-
}
|
|
23
|
-
const channel = new Channel({
|
|
24
|
-
site: 'example.com',
|
|
25
|
-
site_id: 'cnn',
|
|
26
|
-
xmltv_id: 'CNN.us',
|
|
27
|
-
lang: 'en',
|
|
28
|
-
name: 'CNN'
|
|
29
|
-
})
|
|
30
|
-
const grabber = new EPGGrabber(config)
|
|
31
|
-
grabber
|
|
32
|
-
.grab(channel, '2022-01-01', (data, err) => {
|
|
33
|
-
expect(err.message).toBe('Connection timeout')
|
|
34
|
-
done()
|
|
35
|
-
})
|
|
36
|
-
.catch(done)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
10
|
it('can grab single channel programs', done => {
|
|
40
11
|
const data = {
|
|
41
12
|
data: {
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?><tv date="20250716">
|
|
2
|
-
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url><lcn>36</lcn></channel>
|
|
3
|
-
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
|
-
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
|
|
5
|
-
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="2TV.com"><title>Program1</title></programme>
|
|
6
|
-
</tv>
|