diff --git a/scripts/commands/update-api.js b/scripts/commands/update-api.js index 9ddb1800..da548ac6 100644 --- a/scripts/commands/update-api.js +++ b/scripts/commands/update-api.js @@ -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` }) } diff --git a/tests/__data__/expected/api/guides.json b/tests/__data__/expected/api/guides.json index 8c564fdd..fd298d53 100644 --- a/tests/__data__/expected/api/guides.json +++ b/tests/__data__/expected/api/guides.json @@ -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"}] \ No newline at end of file +[{"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"}] \ No newline at end of file diff --git a/tests/commands/update-api.test.js b/tests/commands/update-api.test.js index cb7083df..036ddcfa 100644 --- a/tests/commands/update-api.test.js +++ b/tests/commands/update-api.test.js @@ -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'