mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Delete database/cleanup.js
This commit is contained in:
parent
8ded3338e3
commit
37b77a7d62
6 changed files with 0 additions and 110 deletions
|
@ -1,25 +0,0 @@
|
|||
const { db, logger } = require('../../core')
|
||||
const _ = require('lodash')
|
||||
|
||||
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 failed = _.filter(streams, { status: 'error' })
|
||||
for (const stream of failed) {
|
||||
const hasDuplicate = _.find(streams, s => s.channel === stream.channel && s.status !== 'error')
|
||||
if (hasDuplicate) {
|
||||
await db.streams.remove({ _id: stream._id })
|
||||
removed++
|
||||
}
|
||||
}
|
||||
|
||||
db.streams.compact()
|
||||
|
||||
logger.info(`removed ${removed} links`)
|
||||
}
|
||||
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue