iptv-checker 0.24.1 → 0.24.4
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/.readme/errors.md +2 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/errors.js +2 -1
- package/src/ffprobe.js +2 -0
- package/src/http.js +15 -2
- package/test/index.test.js +15 -3
package/.readme/errors.md
CHANGED
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
| HTTP_NETWORK_UNREACHABLE | HTTP Network Unreachable |
|
|
45
45
|
| HTTP_ECONNRESET | HTTP Connection Reset |
|
|
46
46
|
| HTTP_CONNECTION_REFUSED | HTTP Connection Refused |
|
|
47
|
+
| HTTP_CANNOT_ASSIGN_REQUESTED_ADDRESS | HTTP Cannot Assign Requested Address |
|
|
48
|
+
| HTTP_4XX_CLIENT_ERROR | HTTP 4XX Client Error |
|
|
47
49
|
| HTTP_UNDEFINED | HTTP Undefined Error |
|
|
48
50
|
| FFMPEG_INPUT_OUTPUT_ERROR | FFMPEG Input/output Error |
|
|
49
51
|
| FFMPEG_PROTOCOL_NOT_FOUND | FFMPEG Protocol Not Found |
|
package/README.md
CHANGED
package/package.json
CHANGED
package/src/errors.js
CHANGED
|
@@ -49,8 +49,9 @@ module.exports = {
|
|
|
49
49
|
HTTP_NETWORK_UNREACHABLE: 'HTTP Network Unreachable',
|
|
50
50
|
HTTP_ECONNRESET: 'HTTP Connection Reset',
|
|
51
51
|
HTTP_CONNECTION_REFUSED: 'HTTP Connection Refused',
|
|
52
|
-
HTTP_UNDEFINED: 'HTTP Undefined Error',
|
|
53
52
|
HTTP_CANNOT_ASSIGN_REQUESTED_ADDRESS: 'HTTP Cannot Assign Requested Address',
|
|
53
|
+
HTTP_4XX_CLIENT_ERROR: 'HTTP 4XX Client Error',
|
|
54
|
+
HTTP_UNDEFINED: 'HTTP Undefined Error',
|
|
54
55
|
|
|
55
56
|
FFMPEG_INPUT_OUTPUT_ERROR: 'FFMPEG Input/output Error',
|
|
56
57
|
FFMPEG_PROTOCOL_NOT_FOUND: 'FFMPEG Protocol Not Found',
|
package/src/ffprobe.js
CHANGED
|
@@ -146,6 +146,8 @@ function parseError(output, item, config, logger) {
|
|
|
146
146
|
return 'HTTP_CONNECTION_REFUSED'
|
|
147
147
|
case "Can't assign requested address":
|
|
148
148
|
return 'HTTP_CANNOT_ASSIGN_REQUESTED_ADDRESS'
|
|
149
|
+
case 'Server returned 4XX Client Error, but not one of 40{0,1,3,4}':
|
|
150
|
+
return 'HTTP_4XX_CLIENT_ERROR'
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
logger.debug('FFMPEG_UNDEFINED')
|
package/src/http.js
CHANGED
|
@@ -2,6 +2,7 @@ const curlirize = require('axios-curlirize')
|
|
|
2
2
|
const axios = require('axios')
|
|
3
3
|
const https = require('https')
|
|
4
4
|
const errors = require('./errors')
|
|
5
|
+
const CancelToken = axios.CancelToken
|
|
5
6
|
|
|
6
7
|
module.exports.loadPlaylist = loadPlaylist
|
|
7
8
|
module.exports.loadStream = loadStream
|
|
@@ -32,6 +33,7 @@ playlistClient.interceptors.response.use(
|
|
|
32
33
|
const streamClient = axios.create({
|
|
33
34
|
method: 'GET',
|
|
34
35
|
timeout: 60000,
|
|
36
|
+
maxContentLength: 5 * 1024 * 1024,
|
|
35
37
|
httpsAgent: new https.Agent({
|
|
36
38
|
rejectUnauthorized: false,
|
|
37
39
|
}),
|
|
@@ -68,14 +70,23 @@ function loadStream(item, config, logger) {
|
|
|
68
70
|
headers['Referer'] = referer
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
let source = CancelToken.source()
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
source.cancel('timeout')
|
|
76
|
+
}, timeout)
|
|
77
|
+
|
|
71
78
|
return streamClient(item.url, {
|
|
72
79
|
timeout,
|
|
73
80
|
headers,
|
|
81
|
+
cancelToken: source.token,
|
|
74
82
|
curlirize: config.debug,
|
|
75
83
|
})
|
|
76
84
|
.then(() => Promise.resolve())
|
|
77
85
|
.catch(err => {
|
|
78
86
|
const code = parseError(err, config, logger)
|
|
87
|
+
if (code === 'HTTP_MAX_CONTENT_LENGTH_EXCEEDED') {
|
|
88
|
+
return Promise.resolve()
|
|
89
|
+
}
|
|
79
90
|
|
|
80
91
|
return Promise.reject({
|
|
81
92
|
ok: false,
|
|
@@ -88,10 +99,12 @@ function loadStream(item, config, logger) {
|
|
|
88
99
|
function parseError(err, config, logger) {
|
|
89
100
|
if (err.response) {
|
|
90
101
|
return parseResponseStatus(err.response.status)
|
|
91
|
-
} else if (err.message.startsWith('timeout')) {
|
|
102
|
+
} else if (err.message && err.message.startsWith('timeout')) {
|
|
92
103
|
return 'HTTP_REQUEST_TIMEOUT'
|
|
93
|
-
} else if (err.message.includes('ECONNREFUSED')) {
|
|
104
|
+
} else if (err.message && err.message.includes('ECONNREFUSED')) {
|
|
94
105
|
return 'HTTP_INTERNAL_SERVER_ERROR'
|
|
106
|
+
} else if (err.message && err.message.startsWith('maxContentLength')) {
|
|
107
|
+
return 'HTTP_MAX_CONTENT_LENGTH_EXCEEDED'
|
|
95
108
|
} else if (err.code === 'EPROTO') {
|
|
96
109
|
return 'HTTP_PROTOCOL_ERROR'
|
|
97
110
|
} else if (err.code === 'ENETUNREACH') {
|
package/test/index.test.js
CHANGED
|
@@ -29,10 +29,9 @@ test(`Should process a playlist URL`, done => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
test(`Should process a stream URL`, done => {
|
|
32
|
-
const url =
|
|
33
|
-
'http://cdn.theoplayer.com/video/elephants-dream/playlist-single-audio.m3u8'
|
|
32
|
+
const url = 'https://live-hls-web-aja.getaj.net/AJA/index.m3u8'
|
|
34
33
|
checker
|
|
35
|
-
.checkStream({ url, timeout:
|
|
34
|
+
.checkStream({ url, timeout: 10000 })
|
|
36
35
|
.then(results => {
|
|
37
36
|
expect(results.status.ok).toBeTruthy()
|
|
38
37
|
done()
|
|
@@ -138,3 +137,16 @@ test(`Should handle HTTP_FORBIDDEN`, done => {
|
|
|
138
137
|
})
|
|
139
138
|
.catch(done)
|
|
140
139
|
})
|
|
140
|
+
|
|
141
|
+
test(`Should use timeout parameter`, done => {
|
|
142
|
+
const url =
|
|
143
|
+
'http://hbbtvlive.v3.tvp.pl/hbbtvlive/livestream.php?app_id=tvpbialystok'
|
|
144
|
+
checker
|
|
145
|
+
.checkStream({ url, timeout: 100 })
|
|
146
|
+
.then(results => {
|
|
147
|
+
expect(results.status.code).toBe('HTTP_REQUEST_TIMEOUT')
|
|
148
|
+
expect(results.status.message).toBe('HTTP 408 Request Timeout')
|
|
149
|
+
done()
|
|
150
|
+
})
|
|
151
|
+
.catch(done)
|
|
152
|
+
})
|