2019-10-25 18:11:21 +00:00
|
|
|
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
|
|
|
|
|
2019-11-02 11:10:57 +00:00
|
|
|
const helper = require('./helper')
|
2020-05-26 12:23:22 +00:00
|
|
|
const iptvChecker = require('iptv-checker-module')
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2019-07-20 07:33:16 +00:00
|
|
|
const config = {
|
2019-11-03 17:21:35 +00:00
|
|
|
debug: process.env.npm_config_debug || false,
|
|
|
|
country: process.env.npm_config_country,
|
|
|
|
exclude: process.env.npm_config_exclude,
|
2020-05-27 17:14:06 +00:00
|
|
|
timeout: 10000
|
2019-07-20 07:33:16 +00:00
|
|
|
}
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2019-07-20 07:33:16 +00:00
|
|
|
let stats = {
|
2019-11-03 17:21:35 +00:00
|
|
|
playlists: 0,
|
2019-07-20 07:33:16 +00:00
|
|
|
channels: 0,
|
|
|
|
failures: 0
|
|
|
|
}
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2019-07-20 07:33:16 +00:00
|
|
|
async function test() {
|
2019-11-02 09:45:09 +00:00
|
|
|
const playlist = helper.parsePlaylist('index.m3u')
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2020-04-11 00:54:32 +00:00
|
|
|
const countries = helper.filterPlaylists(playlist.items, config.country, config.exclude)
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2020-04-11 00:54:32 +00:00
|
|
|
for (let country of countries) {
|
2019-11-03 17:21:35 +00:00
|
|
|
stats.playlists++
|
2019-05-09 17:04:18 +00:00
|
|
|
|
2019-11-03 17:21:35 +00:00
|
|
|
console.log(`Processing '${country.url}'...`)
|
2019-08-07 20:59:44 +00:00
|
|
|
|
2020-05-26 12:23:22 +00:00
|
|
|
const options = {
|
|
|
|
timeout: config.timeout,
|
|
|
|
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
|
|
|
|
debug: config.debug,
|
|
|
|
omitMetadata: true,
|
|
|
|
parallel: 1,
|
|
|
|
itemCallback: item => {
|
2020-05-27 17:14:06 +00:00
|
|
|
if (!item.status.ok && item.status.reason !== 'Timed out') {
|
2020-05-26 12:23:22 +00:00
|
|
|
stats.failures++
|
2018-12-22 19:07:47 +00:00
|
|
|
|
2020-05-26 12:23:22 +00:00
|
|
|
helper.writeToLog(country.url, item.status.reason, item.url)
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2020-05-26 12:23:22 +00:00
|
|
|
console.log(`${item.status.reason} '${item.url}'`)
|
|
|
|
}
|
2020-04-11 00:54:32 +00:00
|
|
|
}
|
2018-11-15 23:41:15 +00:00
|
|
|
}
|
2020-05-26 12:23:22 +00:00
|
|
|
|
|
|
|
await iptvChecker(country.url, options)
|
2018-12-22 19:07:47 +00:00
|
|
|
}
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2020-04-11 00:54:32 +00:00
|
|
|
if (stats.failures === 0) {
|
2019-11-03 17:21:35 +00:00
|
|
|
console.log(`OK (${stats.playlists} playlists, ${stats.channels} channels)`)
|
2018-12-22 19:07:47 +00:00
|
|
|
} else {
|
2020-04-11 00:54:32 +00:00
|
|
|
console.log(
|
|
|
|
`FAILURES! (${stats.playlists} playlists, ${stats.channels} channels, ${stats.failures} failures)`
|
|
|
|
)
|
2018-11-15 23:41:15 +00:00
|
|
|
|
2019-09-07 15:24:59 +00:00
|
|
|
process.exit(1)
|
2018-12-22 19:07:47 +00:00
|
|
|
}
|
2018-11-15 23:41:15 +00:00
|
|
|
}
|
|
|
|
|
2018-12-26 19:41:17 +00:00
|
|
|
console.log('Test is running...')
|
|
|
|
|
2019-07-20 07:33:16 +00:00
|
|
|
test()
|