diff --git a/scripts/commands/guides/update.js b/scripts/commands/guides/update.js index aaf509e8..ab4ccde5 100644 --- a/scripts/commands/guides/update.js +++ b/scripts/commands/guides/update.js @@ -1,4 +1,4 @@ -const { db, logger, file, api, zip } = require('../../core') +const { db, logger, file, zip } = require('../../core') const { generateXMLTV, Program, Channel } = require('epg-grabber') const _ = require('lodash') @@ -10,7 +10,6 @@ async function main() { logger.info('Loading "database/programs.db"...') await db.programs.load() - await api.channels.load() let total = 0 const grouped = groupByGroup(await loadQueue()) @@ -24,10 +23,7 @@ async function main() { programs = programs.concat(itemPrograms) if (channels[item.channel.id]) continue - const found = api.channels.find({ id: item.channel.id }) - if (found) { - channels[item.channel.id] = new Channel(item.channel) - } + channels[item.channel.id] = new Channel(item.channel) } channels = Object.values(channels) channels = _.sortBy(channels, 'id') diff --git a/scripts/commands/queue/create.js b/scripts/commands/queue/create.js index 062135b5..c09baf53 100644 --- a/scripts/commands/queue/create.js +++ b/scripts/commands/queue/create.js @@ -51,6 +51,7 @@ async function createQueue() { if (!channel.site || !channel.id) continue const found = api.channels.find({ id: channel.id }) if (!found) continue + channel.logo = found.logo for (const d of dates) { const dString = d.toJSON() const key = `${channel.site}:${channel.lang}:${channel.id}:${dString}` diff --git a/tests/__data__/expected/database/create-queue/queue.db b/tests/__data__/expected/database/create-queue/queue.db index d9060a68..74a96e62 100644 --- a/tests/__data__/expected/database/create-queue/queue.db +++ b/tests/__data__/expected/database/create-queue/queue.db @@ -1,4 +1,4 @@ -{"channel":{"lang":"en","id":"CNNInternationalEurope.us","name":"CNN International","logo":"","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-03T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-en/example.com"],"error":null,"cluster_id":1,"_id":"vOpwztzvJ5pFSVws"} -{"channel":{"lang":"en","id":"CNNInternationalEurope.us","name":"CNN International","logo":"","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-04T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-en/example.com"],"error":null,"cluster_id":1,"_id":"sP2A0zQSOoVg0BS1"} -{"channel":{"lang":"ru","id":"CNNInternationalEurope.us","name":"CNN International","logo":"","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-03T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-ru/example.com"],"error":null,"cluster_id":1,"_id":"vOpwztzvJ5pFSVwB"} -{"channel":{"lang":"ru","id":"CNNInternationalEurope.us","name":"CNN International","logo":"","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-04T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-ru/example.com"],"error":null,"cluster_id":1,"_id":"sP2A0zQSOoVg0BSB"} \ No newline at end of file +{"channel":{"lang":"en","id":"CNNInternationalEurope.us","name":"CNN International","logo":"https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/CNN_International_logo.svg/512px-CNN_International_logo.svg.png","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-03T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-en/example.com"],"error":null,"cluster_id":1,"_id":"vOpwztzvJ5pFSVws"} +{"channel":{"lang":"en","id":"CNNInternationalEurope.us","name":"CNN International","logo":"https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/CNN_International_logo.svg/512px-CNN_International_logo.svg.png","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-04T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-en/example.com"],"error":null,"cluster_id":1,"_id":"sP2A0zQSOoVg0BS1"} +{"channel":{"lang":"ru","id":"CNNInternationalEurope.us","name":"CNN International","logo":"https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/CNN_International_logo.svg/512px-CNN_International_logo.svg.png","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-03T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-ru/example.com"],"error":null,"cluster_id":1,"_id":"vOpwztzvJ5pFSVwB"} +{"channel":{"lang":"ru","id":"CNNInternationalEurope.us","name":"CNN International","logo":"https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/CNN_International_logo.svg/512px-CNN_International_logo.svg.png","url":"https://example.com","site_id":"140","site":"example.com"},"date":"2022-02-04T00:00:00.000Z","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ca-ru/example.com"],"error":null,"cluster_id":1,"_id":"sP2A0zQSOoVg0BSB"} \ No newline at end of file