mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Update .gitignore
This commit is contained in:
parent
90c8aca0e6
commit
b39dc83f8b
5 changed files with 301 additions and 2 deletions
25
scripts/commands/database/cleanup.js
Normal file
25
scripts/commands/database/cleanup.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
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()
|
Loading…
Add table
Add a link
Reference in a new issue