From 65e76c926de9b31ddf667440dd6aec61cbdc4f57 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 31 Dec 2021 11:06:41 +0300 Subject: [PATCH] Update generate-playlists.js --- scripts/commands/generate-playlists.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/commands/generate-playlists.js b/scripts/commands/generate-playlists.js index f28112188a..fcfec56c63 100644 --- a/scripts/commands/generate-playlists.js +++ b/scripts/commands/generate-playlists.js @@ -226,7 +226,7 @@ async function generateIndexLanguage() { { onLoad: function (items) { let results = items - .filter(item => !item.languages.length) + .filter(item => !item.languages || !item.languages.length) .map(item => { const newItem = _.cloneDeep(item) newItem.group_title = '' @@ -235,7 +235,7 @@ async function generateIndexLanguage() { for (const language of languages) { let filtered = items .filter(item => { - return item.languages.map(c => c.code).includes(language.code) + return item.languages && item.languages.map(c => c.code).includes(language.code) }) .map(item => { const newItem = _.cloneDeep(item) @@ -296,10 +296,10 @@ async function generateChannelsJson() { async function setUp() { logger.info(`Loading database...`) const items = await db.find({}) - categories = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.categories)), 'slug'), ['name']) - countries = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.countries)), 'code'), ['name']) - languages = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.languages)), 'code'), ['name']) - regions = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.regions)), 'code'), ['name']) + categories = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.categories)), 'slug'), ['name']).filter(i => i) + countries = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.countries)), 'code'), ['name']).filter(i => i) + languages = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.languages)), 'code'), ['name']).filter(i => i) + regions = _.sortBy(_.uniqBy(_.flatten(items.map(i => i.regions)), 'code'), ['name']).filter(i => i) const categoriesLog = `${LOGS_PATH}/generate-playlists/categories.log` const countriesLog = `${LOGS_PATH}/generate-playlists/countries.log`