Update update-api.js

This commit is contained in:
Aleksandr Statciuk 2022-01-30 03:09:33 +03:00
parent 4e28c1a119
commit 8baeed2247
3 changed files with 10 additions and 14 deletions

View File

@ -14,19 +14,18 @@ main()
async function loadGuides() {
logger.info('Loading guides from database...')
await db.channels.load()
await db.queue.load()
const channels = await db.channels.find({}).sort({ xmltv_id: 1 })
const queue = await db.queue.find({}).sort({ xmltv_id: 1 })
const output = []
for (const channel of channels) {
channel.groups.forEach(group => {
if (channel.programCount) {
for (const item of queue) {
item.groups.forEach(group => {
if (item.programCount) {
output.push({
channel: channel.xmltv_id,
display_name: channel.name,
site: channel.site,
lang: channel.lang,
channel: item.xmltv_id,
site: item.site,
lang: item.lang,
url: `https://iptv-org.github.io/epg/guides/${group}.epg.xml`
})
}

View File

@ -1 +1 @@
[{"channel":"CNNInternationalEurope.us","display_name":"CNN International Europe","site":"chaines-tv.orange.fr","lang":"fr","url":"https://iptv-org.github.io/epg/guides/fr/chaines-tv.orange.fr.epg.xml"},{"channel":"CNNInternationalEurope.us","display_name":"CNN International Europe","site":"chaines-tv.orange.fr","lang":"fr","url":"https://iptv-org.github.io/epg/guides/bh/chaines-tv.orange.fr.epg.xml"},{"channel":"MNetMovies2.za","display_name":"M-Net Movies 2","site":"dstv.com","lang":"en","url":"https://iptv-org.github.io/epg/guides/zw/dstv.com.epg.xml"}]
[{"channel":"CNNInternationalEurope.us","site":"chaines-tv.orange.fr","lang":"fr","url":"https://iptv-org.github.io/epg/guides/fr/chaines-tv.orange.fr.epg.xml"},{"channel":"CNNInternationalEurope.us","site":"chaines-tv.orange.fr","lang":"fr","url":"https://iptv-org.github.io/epg/guides/bh/chaines-tv.orange.fr.epg.xml"},{"channel":"MNetMovies2.za","site":"dstv.com","lang":"en","url":"https://iptv-org.github.io/epg/guides/zw/dstv.com.epg.xml"}]

View File

@ -6,10 +6,7 @@ beforeEach(() => {
fs.rmdirSync('tests/__data__/output', { recursive: true })
fs.mkdirSync('tests/__data__/output')
fs.mkdirSync('tests/__data__/temp/database', { recursive: true })
fs.copyFileSync(
'tests/__data__/input/database/channels.db',
'tests/__data__/temp/database/channels.db'
)
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/temp/database/queue.db')
fs.copyFileSync(
'tests/__data__/input/database/programs.db',
'tests/__data__/temp/database/programs.db'