epg-grabber 0.40.4 → 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 -17
- package/src/client.js +5 -10
- package/src/file.js +2 -6
- package/src/utils.js +9 -5
- package/tests/index.test.js +0 -29
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,30 +30,30 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"axios": "^1.6.1",
|
|
33
|
-
"axios-cache-interceptor": "^
|
|
34
|
-
"commander": "^
|
|
35
|
-
"curl-generator": "^0.2
|
|
33
|
+
"axios-cache-interceptor": "^1.8.0",
|
|
34
|
+
"commander": "^14.0.0",
|
|
35
|
+
"curl-generator": "^0.4.2",
|
|
36
36
|
"cwait": "^1.1.2",
|
|
37
|
-
"dayjs": "^1.
|
|
38
|
-
"epg-parser": "^0.1
|
|
39
|
-
"fs-extra": "^11.
|
|
40
|
-
"glob": "^
|
|
37
|
+
"dayjs": "^1.11.13",
|
|
38
|
+
"epg-parser": "^0.3.1",
|
|
39
|
+
"fs-extra": "^11.3.0",
|
|
40
|
+
"glob": "^11.0.3",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"node-gzip": "^1.1.2",
|
|
43
43
|
"socks-proxy-agent": "^8.0.5",
|
|
44
|
-
"winston": "^3.
|
|
44
|
+
"winston": "^3.17.0",
|
|
45
45
|
"xml-js": "^1.6.11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/core": "^7.13.14",
|
|
49
|
-
"@babel/preset-env": "^7.
|
|
50
|
-
"@eslint/eslintrc": "^3.
|
|
51
|
-
"@eslint/js": "^9.
|
|
52
|
-
"babel-jest": "^
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"globals": "^
|
|
55
|
-
"jest": "^
|
|
56
|
-
"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"
|
|
57
57
|
},
|
|
58
58
|
"jest": {
|
|
59
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) {
|
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: {
|