mirror of
https://github.com/iptv-org/iptv.git
synced 2024-09-05 00:01:35 +02:00
26 lines
620 B
JavaScript
26 lines
620 B
JavaScript
const { db, logger } = require('../../core')
|
|
|
|
async function main() {
|
|
logger.info(`loading streams...`)
|
|
await db.streams.load()
|
|
let streams = await db.streams.find({})
|
|
|
|
logger.info(`removing broken links...`)
|
|
let removed = 0
|
|
const buffer = {}
|
|
for (const stream of streams) {
|
|
const duplicate = buffer[stream.channel_id]
|
|
if (duplicate && ['offline', 'timeout'].includes(stream.status.code)) {
|
|
await db.streams.remove({ _id: stream._id })
|
|
removed++
|
|
} else {
|
|
buffer[stream.channel_id] = stream
|
|
}
|
|
}
|
|
db.streams.compact()
|
|
|
|
logger.info(`removed ${removed} links`)
|
|
}
|
|
|
|
main()
|