mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Move scripts to subfolders
This commit is contained in:
parent
f0c64a55e4
commit
b1a0bcf4b9
36 changed files with 204 additions and 222 deletions
|
@ -1,44 +0,0 @@
|
|||
const { db, logger, file, parser } = require('../core')
|
||||
const _ = require('lodash')
|
||||
|
||||
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||
|
||||
async function main() {
|
||||
await db.queue.load()
|
||||
await db.programs.load()
|
||||
await db.programs.reset()
|
||||
const files = await file.list(`${LOGS_DIR}/load-cluster/cluster_*.log`)
|
||||
for (const filepath of files) {
|
||||
logger.info(`Parsing "${filepath}"...`)
|
||||
const results = await parser.parseLogs(filepath)
|
||||
for (const result of results) {
|
||||
const queue = await db.queue.find({ _id: result._qid }).limit(1)
|
||||
if (!queue.length) continue
|
||||
const item = queue[0]
|
||||
const programs = result.programs.map(program => {
|
||||
return {
|
||||
title: program.title,
|
||||
description: program.description || null,
|
||||
category: program.category || null,
|
||||
season: program.season || null,
|
||||
episode: program.episode || null,
|
||||
icon: program.icon || null,
|
||||
channel: program.channel,
|
||||
lang: program.lang,
|
||||
start: program.start,
|
||||
stop: program.stop,
|
||||
stop: program.stop,
|
||||
site: item.channel.site,
|
||||
_qid: result._qid
|
||||
}
|
||||
})
|
||||
await db.programs.insert(programs)
|
||||
|
||||
await db.queue.update({ _id: result._qid }, { $set: { error: result.error } })
|
||||
}
|
||||
}
|
||||
|
||||
await db.queue.compact()
|
||||
}
|
||||
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue