Delete clear.js
This commit is contained in:
parent
0155e15b3e
commit
1011925cfe
|
@ -1,41 +0,0 @@
|
||||||
const parser = require('./helpers/parser')
|
|
||||||
const utils = require('./helpers/utils')
|
|
||||||
const log = require('./helpers/log')
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
log.start()
|
|
||||||
|
|
||||||
log.print(`Parsing 'index.m3u'...`)
|
|
||||||
const playlists = parser.parseIndex().filter(i => i.url !== 'channels/unsorted.m3u')
|
|
||||||
for (const playlist of playlists) {
|
|
||||||
log.print(`\nProcessing '${playlist.url}'...`)
|
|
||||||
await parser
|
|
||||||
.parsePlaylist(playlist.url)
|
|
||||||
.then(removeBrokenLinks)
|
|
||||||
.then(p => p.save())
|
|
||||||
}
|
|
||||||
|
|
||||||
log.print('\n')
|
|
||||||
log.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeBrokenLinks(playlist) {
|
|
||||||
const buffer = []
|
|
||||||
const channels = playlist.channels.filter(channel => {
|
|
||||||
const sameHash = buffer.find(item => item.hash === channel.hash)
|
|
||||||
if (sameHash && channel.status === 'Offline') return false
|
|
||||||
|
|
||||||
buffer.push(channel)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
if (playlist.channels.length !== channels.length) {
|
|
||||||
log.print('updated')
|
|
||||||
playlist.channels = channels
|
|
||||||
playlist.updated = true
|
|
||||||
}
|
|
||||||
|
|
||||||
return playlist
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
Loading…
Reference in New Issue