mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update create.js
This commit is contained in:
parent
6a89e53a1d
commit
0de4ee66d1
1 changed files with 47 additions and 43 deletions
|
@ -37,53 +37,57 @@ async function createQueue() {
|
||||||
const utcDate = date.getUTC()
|
const utcDate = date.getUTC()
|
||||||
const dates = Array.from({ length: options.days }, (_, i) => utcDate.add(i, 'd'))
|
const dates = Array.from({ length: options.days }, (_, i) => utcDate.add(i, 'd'))
|
||||||
for (const filepath of files) {
|
for (const filepath of files) {
|
||||||
const dir = file.dirname(filepath)
|
try {
|
||||||
const { site, channels: items } = await parser.parseChannels(filepath)
|
const dir = file.dirname(filepath)
|
||||||
if (!site) continue
|
const { site, channels: items } = await parser.parseChannels(filepath)
|
||||||
const configPath = `${dir}/${site}.config.js`
|
if (!site) continue
|
||||||
const config = require(file.resolve(configPath))
|
const configPath = `${dir}/${site}.config.js`
|
||||||
if (config.ignore) continue
|
const config = require(file.resolve(configPath))
|
||||||
const filename = file.basename(filepath)
|
if (config.ignore) continue
|
||||||
const [__, region] = filename.match(/_([a-z-]+)\.channels\.xml/i) || [null, null]
|
const filename = file.basename(filepath)
|
||||||
const groupId = `${region}/${site}`
|
const [__, region] = filename.match(/_([a-z-]+)\.channels\.xml/i) || [null, null]
|
||||||
for (const item of items) {
|
const groupId = `${region}/${site}`
|
||||||
if (!item.site || !item.site_id || !item.xmltv_id) continue
|
for (const item of items) {
|
||||||
const channel = api.channels.find({ id: item.xmltv_id })
|
if (!item.site || !item.site_id || !item.xmltv_id) continue
|
||||||
if (!channel) {
|
const channel = api.channels.find({ id: item.xmltv_id })
|
||||||
await logError(groupId, {
|
if (!channel) {
|
||||||
xmltv_id: item.xmltv_id,
|
await logError(groupId, {
|
||||||
site: item.site,
|
xmltv_id: item.xmltv_id,
|
||||||
site_id: item.site_id,
|
site: item.site,
|
||||||
lang: item.lang,
|
site_id: item.site_id,
|
||||||
date: undefined,
|
lang: item.lang,
|
||||||
error: 'The channel has the wrong xmltv_id'
|
date: undefined,
|
||||||
})
|
error: 'The channel has the wrong xmltv_id'
|
||||||
continue
|
})
|
||||||
}
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for (const d of dates) {
|
for (const d of dates) {
|
||||||
const dString = d.toJSON()
|
const dString = d.toJSON()
|
||||||
const key = `${item.site}:${item.lang}:${item.xmltv_id}:${dString}`
|
const key = `${item.site}:${item.lang}:${item.xmltv_id}:${dString}`
|
||||||
if (!queue[key]) {
|
if (!queue[key]) {
|
||||||
queue[key] = {
|
queue[key] = {
|
||||||
channel: {
|
channel: {
|
||||||
lang: item.lang,
|
lang: item.lang,
|
||||||
xmltv_id: item.xmltv_id,
|
xmltv_id: item.xmltv_id,
|
||||||
display_name: item.name,
|
display_name: item.name,
|
||||||
site_id: item.site_id,
|
site_id: item.site_id,
|
||||||
site: item.site
|
site: item.site
|
||||||
},
|
},
|
||||||
date: dString,
|
date: dString,
|
||||||
configPath,
|
configPath,
|
||||||
groups: [],
|
groups: [],
|
||||||
error: null
|
error: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!queue[key].groups.includes(groupId)) {
|
||||||
|
queue[key].groups.push(groupId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue[key].groups.includes(groupId)) {
|
|
||||||
queue[key].groups.push(groupId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue