mirror of
https://github.com/iptv-org/epg
synced 2025-12-17 10:56:57 -05:00
Update update-api.js
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user