Update create.js

This commit is contained in:
Aleksandr Statciuk 2022-03-03 21:12:38 +03:00
parent 259a8100f7
commit ec57059055

View file

@ -48,20 +48,9 @@ async function createQueue() {
const [__, region] = filename.match(/_([a-z-]+)\.channels\.xml/i) || [null, null]
const groupId = `${region}/${site}`
for (const item of items) {
if (!item.site || !item.site_id || !item.xmltv_id) continue
if (!item.site || !item.xmltv_id) continue
const channel = api.channels.find({ id: item.xmltv_id })
if (!channel) {
await logError(groupId, {
xmltv_id: item.xmltv_id,
site: item.site,
site_id: item.site_id,
lang: item.lang,
date: undefined,
error: 'The channel has the wrong xmltv_id'
})
continue
}
if (!channel) continue
for (const d of dates) {
const dString = d.toJSON()
const key = `${item.site}:${item.lang}:${item.xmltv_id}:${dString}`
@ -123,12 +112,3 @@ 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')
}