Update clean.js
This commit is contained in:
parent
2a83eb675d
commit
e9f5494a29
|
@ -51,7 +51,7 @@ async function checkStatus(playlist) {
|
||||||
let bar = new ProgressBar(`Checking '${playlist.url}': [:bar] :current/:total (:percent) `, {
|
let bar = new ProgressBar(`Checking '${playlist.url}': [:bar] :current/:total (:percent) `, {
|
||||||
total: playlist.channels.length
|
total: playlist.channels.length
|
||||||
})
|
})
|
||||||
const results = []
|
const channels = []
|
||||||
const total = playlist.channels.length
|
const total = playlist.channels.length
|
||||||
for (const [index, channel] of playlist.channels.entries()) {
|
for (const [index, channel] of playlist.channels.entries()) {
|
||||||
const current = index + 1
|
const current = index + 1
|
||||||
|
@ -61,7 +61,7 @@ async function checkStatus(playlist) {
|
||||||
(channel.status && ignore.map(i => i.toLowerCase()).includes(channel.status.toLowerCase())) ||
|
(channel.status && ignore.map(i => i.toLowerCase()).includes(channel.status.toLowerCase())) ||
|
||||||
(!channel.url.startsWith('http://') && !channel.url.startsWith('https://'))
|
(!channel.url.startsWith('http://') && !channel.url.startsWith('https://'))
|
||||||
) {
|
) {
|
||||||
results.push(channel)
|
channels.push(channel)
|
||||||
} else {
|
} else {
|
||||||
const CancelToken = axios.CancelToken
|
const CancelToken = axios.CancelToken
|
||||||
const source = CancelToken.source()
|
const source = CancelToken.source()
|
||||||
|
@ -73,7 +73,7 @@ async function checkStatus(playlist) {
|
||||||
.get(channel.url, { cancelToken: source.token })
|
.get(channel.url, { cancelToken: source.token })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
results.push(channel)
|
channels.push(channel)
|
||||||
})
|
})
|
||||||
.then(utils.sleep(config.delay))
|
.then(utils.sleep(config.delay))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
@ -81,13 +81,16 @@ async function checkStatus(playlist) {
|
||||||
if (err.response && offlineStatusCodes.includes(err.response.status)) {
|
if (err.response && offlineStatusCodes.includes(err.response.status)) {
|
||||||
broken++
|
broken++
|
||||||
} else {
|
} else {
|
||||||
results.push(channel)
|
channels.push(channel)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.channels = results
|
if (playlist.channels.length !== channels.length) {
|
||||||
|
log.print(`File '${playlist.url}' has been updated\n`)
|
||||||
|
playlist.channels = channels
|
||||||
|
}
|
||||||
|
|
||||||
return playlist
|
return playlist
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue