Fixes missing channel logo issue

This commit is contained in:
Aleksandr Statciuk 2022-06-17 20:00:23 +03:00
parent ad9c5c9312
commit 588d5b73cf
3 changed files with 7 additions and 10 deletions

View file

@ -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')

View file

@ -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}`

View file

@ -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"}
{"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"}