Merge pull request #3057 from iptv-org/update-clean-action

Update clean action
pull/3072/head^2
Aleksandr Statciuk 4 years ago committed by GitHub
commit 5ca84e3b6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,7 +10,8 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
country: [ country:
[
ad, ad,
ae, ae,
af, af,
@ -166,8 +167,8 @@ jobs:
vn, vn,
xk, xk,
ye, ye,
zm zm,
# unsorted unsorted
] ]
steps: steps:
- name: Checkout - name: Checkout

@ -17,6 +17,7 @@ program
const config = program.opts() const config = program.opts()
const offlineStatusCodes = [404, 410, 500, 501]
const instance = axios.create({ const instance = axios.create({
timeout: config.timeout, timeout: config.timeout,
maxContentLength: 200000, maxContentLength: 200000,
@ -24,7 +25,7 @@ const instance = axios.create({
rejectUnauthorized: false rejectUnauthorized: false
}), }),
validateStatus: function (status) { validateStatus: function (status) {
return status !== 404 return !offlineStatusCodes.includes(status)
} }
}) })
@ -34,7 +35,7 @@ const stats = { broken: 0 }
async function main() { async function main() {
console.info(`\nStarting...`) console.info(`\nStarting...`)
console.time('Process completed in') console.time('Done in')
if (config.debug) { if (config.debug) {
console.info(chalk.yellow(`INFO: Debug mode enabled\n`)) console.info(chalk.yellow(`INFO: Debug mode enabled\n`))
} }
@ -101,12 +102,11 @@ async function checkStatus(playlist) {
.then(utils.sleep(config.delay)) .then(utils.sleep(config.delay))
.catch(err => { .catch(err => {
clearTimeout(timeout) clearTimeout(timeout)
if (err.response && err.response.status === 404) { if (err.response && offlineStatusCodes.includes(err.response.status)) {
//console.error(err)
if (config.debug) { if (config.debug) {
console.info(` ${counter} ${chalk.red('offline')} ${chalk.white(channel.url)}`) console.info(` ${counter} ${chalk.red('offline')} ${chalk.white(channel.url)}`)
stats.broken++
} }
stats.broken++
} else { } else {
results.push(channel) results.push(channel)
if (config.debug) { if (config.debug) {
@ -131,7 +131,7 @@ async function savePlaylist(playlist) {
return false return false
} else { } else {
utils.createFile(playlist.url, output) utils.createFile(playlist.url, output)
console.info(`Playlist has been updated. Removed ${stats.broken} broken links.`) console.info(`Playlist has been updated. Removed ${stats.broken} links.`)
} }
return true return true
@ -142,7 +142,7 @@ async function done() {
} }
function finish() { function finish() {
console.timeEnd('Process completed in') console.timeEnd('Done in')
} }
main() main()

Loading…
Cancel
Save