mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update save-results.js
This commit is contained in:
parent
642b09051f
commit
15e54da0e2
4 changed files with 41 additions and 17 deletions
|
@ -4,8 +4,9 @@ const _ = require('lodash')
|
|||
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||
|
||||
async function main() {
|
||||
const errorsLog = `${LOGS_DIR}/errors.log`
|
||||
await file.create(errorsLog)
|
||||
await db.channels.load()
|
||||
|
||||
await db.programs.load()
|
||||
await db.programs.reset()
|
||||
const files = await file.list(`${LOGS_DIR}/load-cluster/cluster_*.log`)
|
||||
|
@ -13,8 +14,6 @@ async function main() {
|
|||
logger.info(`Parsing "${filepath}"...`)
|
||||
const results = await parser.parseLogs(filepath)
|
||||
for (const result of results) {
|
||||
await db.channels.update({ _id: result._id }, { $set: { logo: result.logo } })
|
||||
|
||||
const programs = result.programs.map(program => {
|
||||
return {
|
||||
title: program.title,
|
||||
|
@ -27,13 +26,24 @@ async function main() {
|
|||
lang: program.lang,
|
||||
start: program.start,
|
||||
stop: program.stop,
|
||||
site: result.site,
|
||||
country: result.country,
|
||||
gid: result.gid
|
||||
_cid: result.channel._id
|
||||
}
|
||||
})
|
||||
|
||||
await db.programs.insert(programs)
|
||||
|
||||
if (result.channel.logo) {
|
||||
await db.channels.update(
|
||||
{ _id: result.channel._id },
|
||||
{ $set: { logo: result.channel.logo } }
|
||||
)
|
||||
}
|
||||
|
||||
if (result.error) {
|
||||
await file.append(
|
||||
errorsLog,
|
||||
JSON.stringify({ ...result.channel, date: result.date, error: result.error }) + '\n'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue