mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update create-queue.js
This commit is contained in:
parent
bebee295a3
commit
f147a74e44
1 changed files with 19 additions and 1 deletions
|
@ -14,6 +14,7 @@ const options = program
|
|||
.opts()
|
||||
|
||||
const CHANNELS_PATH = process.env.CHANNELS_PATH || 'sites/**/*.channels.xml'
|
||||
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||
|
||||
async function main() {
|
||||
logger.info('Starting...')
|
||||
|
@ -49,9 +50,17 @@ async function createQueue() {
|
|||
if (!item.site || !item.site_id || !item.xmltv_id) continue
|
||||
const channel = api.channels.find({ id: item.xmltv_id })
|
||||
if (!channel) {
|
||||
console.log(item.xmltv_id)
|
||||
await logError(groupId, {
|
||||
xmltv_id: item.xmltv_id,
|
||||
site: item.site,
|
||||
site_id: item.site_id,
|
||||
lang: item.lang,
|
||||
date: undefined,
|
||||
error: 'Wrong channel ID'
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
for (const d of dates) {
|
||||
const dString = d.toJSON()
|
||||
const key = `${item.site}:${item.site_id}:${item.lang}:${dString}`
|
||||
|
@ -104,3 +113,12 @@ function split(arr, n) {
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
async function logError(key, data) {
|
||||
const filepath = `${LOGS_DIR}/errors/${key}.log`
|
||||
if (!(await file.exists(filepath))) {
|
||||
await file.create(filepath)
|
||||
}
|
||||
|
||||
await file.append(filepath, JSON.stringify(data) + '\r\n')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue