mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update update-api.js
This commit is contained in:
parent
cba419710c
commit
d6c1ff4482
1 changed files with 13 additions and 5 deletions
|
@ -15,14 +15,22 @@ async function generateChannelsJson() {
|
||||||
|
|
||||||
const channels = await loadChannels()
|
const channels = await loadChannels()
|
||||||
|
|
||||||
await file.create(`${API_DIR}/channels.json`, JSON.stringify(channels))
|
const channelsPath = `${API_DIR}/channels.json`
|
||||||
|
logger.info(`Saving to "${channelsPath}"...`)
|
||||||
|
await file.create(channelsPath, JSON.stringify(channels))
|
||||||
|
|
||||||
|
logger.info(`Done`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadChannels() {
|
async function loadChannels() {
|
||||||
let items = await db.channels.find({}).sort({ xmltv_id: 1 })
|
logger.info('Loading channels from database...')
|
||||||
|
|
||||||
let output = {}
|
await db.channels.load()
|
||||||
items.forEach(item => {
|
|
||||||
|
const items = await db.channels.find({}).sort({ xmltv_id: 1 })
|
||||||
|
|
||||||
|
const output = {}
|
||||||
|
for (const item of items) {
|
||||||
if (!output[item.xmltv_id]) {
|
if (!output[item.xmltv_id]) {
|
||||||
output[item.xmltv_id] = {
|
output[item.xmltv_id] = {
|
||||||
id: item.xmltv_id,
|
id: item.xmltv_id,
|
||||||
|
@ -40,7 +48,7 @@ async function loadChannels() {
|
||||||
output[item.xmltv_id].guides.push(
|
output[item.xmltv_id].guides.push(
|
||||||
`https://iptv-org.github.io/epg/guides/${item.gid}/${item.site}.epg.xml`
|
`https://iptv-org.github.io/epg/guides/${item.gid}/${item.site}.epg.xml`
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
|
||||||
return Object.values(output)
|
return Object.values(output)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue