diff --git a/scripts/commands/generate-playlists.js b/scripts/commands/generate-playlists.js index 10d0973ef2..485ef19b72 100644 --- a/scripts/commands/generate-playlists.js +++ b/scripts/commands/generate-playlists.js @@ -48,7 +48,15 @@ async function generateCategories() { const { count: otherCount } = await generator.generate( `${PUBLIC_PATH}/categories/other.m3u`, { categories: { $size: 0 } }, - { saveEmpty: true } + { + saveEmpty: true, + onLoad: function (items) { + return items.map(item => { + item.group_title = 'Other' + return item + }) + } + } ) await log('categories', { @@ -80,6 +88,14 @@ async function generateCountries() { `${PUBLIC_PATH}/countries/undefined.m3u`, { countries: { $size: 0 } + }, + { + onLoad: function (items) { + return items.map(item => { + item.group_title = 'Undefined' + return item + }) + } } ) @@ -109,6 +125,14 @@ async function generateLanguages() { `${PUBLIC_PATH}/languages/undefined.m3u`, { languages: { $size: 0 } + }, + { + onLoad: function (items) { + return items.map(item => { + item.group_title = 'Undefined' + return item + }) + } } ) @@ -140,7 +164,15 @@ async function generateRegions() { const { count: undefinedCount } = await generator.generate( `${PUBLIC_PATH}/regions/undefined.m3u`, { regions: { $size: 0 } }, - { saveEmpty: true } + { + saveEmpty: true, + onLoad: function (items) { + return items.map(item => { + item.group_title = 'Undefined' + return item + }) + } + } ) await log('regions', { @@ -153,13 +185,50 @@ async function generateRegions() { async function generateIndexNSFW() { logger.info(`Generating index.nsfw.m3u...`) - await generator.generate(`${PUBLIC_PATH}/index.nsfw.m3u`, {}, { includeNSFW: true }) + await generator.generate( + `${PUBLIC_PATH}/index.nsfw.m3u`, + {}, + { + includeNSFW: true, + onLoad: function (items) { + return items.map(item => { + if (!item.categories || !item.categories.length) { + item.group_title = 'Other' + } + + return item + }) + }, + sortBy: item => { + if (item.group_title === 'Other') return '_' + return item.group_title || '' + } + } + ) } async function generateIndex() { logger.info(`Generating index.m3u...`) - await generator.generate(`${PUBLIC_PATH}/index.m3u`, {}) + await generator.generate( + `${PUBLIC_PATH}/index.m3u`, + {}, + { + onLoad: function (items) { + return items.map(item => { + if (!item.categories || !item.categories.length) { + item.group_title = 'Other' + } + + return item + }) + }, + sortBy: item => { + if (item.group_title === 'Other') return '_' + return item.group_title || '' + } + } + ) } async function generateIndexCategory() { @@ -168,19 +237,22 @@ async function generateIndexCategory() { await generator.generate( `${PUBLIC_PATH}/index.category.m3u`, {}, - { + { onLoad: function (items) { let results = items .filter(item => !item.categories || !item.categories.length) .map(item => { const newItem = _.cloneDeep(item) - newItem.group_title = '' + newItem.group_title = 'Other' return newItem }) for (const category of _.sortBy(Object.values(categories), ['name'])) { let filtered = items .filter(item => { - return Array.isArray(item.categories) && item.categories.map(c => c.slug).includes(category.slug) + return ( + Array.isArray(item.categories) && + item.categories.map(c => c.slug).includes(category.slug) + ) }) .map(item => { const newItem = _.cloneDeep(item) @@ -192,7 +264,11 @@ async function generateIndexCategory() { return results }, - sortBy: item => item.group_title } + sortBy: item => { + if (item.group_title === 'Other') return '_' + return item.group_title + } + } ) } @@ -208,14 +284,17 @@ async function generateIndexCountry() { .filter(item => !item.countries || !item.countries.length) .map(item => { const newItem = _.cloneDeep(item) - newItem.group_title = '' + newItem.group_title = 'Undefined' newItem.categories = [] return newItem }) for (const country of _.sortBy(Object.values(countries), ['name'])) { let filtered = items .filter(item => { - return Array.isArray(item.countries) && item.countries.map(c => c.code).includes(country.code) + return ( + Array.isArray(item.countries) && + item.countries.map(c => c.code).includes(country.code) + ) }) .map(item => { const newItem = _.cloneDeep(item) @@ -227,7 +306,10 @@ async function generateIndexCountry() { return results }, - sortBy: item => item.group_title + sortBy: item => { + if (item.group_title === 'Undefined') return '_' + return item.group_title + } } ) } @@ -244,14 +326,17 @@ async function generateIndexLanguage() { .filter(item => !item.languages || !item.languages.length) .map(item => { const newItem = _.cloneDeep(item) - newItem.group_title = '' + newItem.group_title = 'Undefined' newItem.categories = [] return newItem }) for (const language of languages) { let filtered = items .filter(item => { - return Array.isArray(item.languages) && item.languages.map(c => c.code).includes(language.code) + return ( + Array.isArray(item.languages) && + item.languages.map(c => c.code).includes(language.code) + ) }) .map(item => { const newItem = _.cloneDeep(item) @@ -263,7 +348,10 @@ async function generateIndexLanguage() { return results }, - sortBy: item => item.group_title + sortBy: item => { + if (item.group_title === 'Undefined') return '_' + return item.group_title + } } ) } @@ -280,7 +368,7 @@ async function generateIndexRegion() { .filter(item => !item.regions.length) .map(item => { const newItem = _.cloneDeep(item) - newItem.group_title = '' + newItem.group_title = 'Undefined' newItem.categories = [] return newItem }) @@ -299,7 +387,10 @@ async function generateIndexRegion() { return results }, - sortBy: item => item.group_title + sortBy: item => { + if (item.group_title === 'Undefined') return '_' + return item.group_title + } } ) } @@ -307,16 +398,28 @@ async function generateIndexRegion() { async function generateChannelsJson() { logger.info('Generating channels.json...') - await generator.generate(`${PUBLIC_PATH}/channels.json`, {}, { format: 'json', includeNSFW: true, uniqBy: null }) + await generator.generate( + `${PUBLIC_PATH}/channels.json`, + {}, + { format: 'json', includeNSFW: true, uniqBy: null } + ) } async function setUp() { logger.info(`Loading database...`) const items = await db.find({}) - 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) + 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` diff --git a/tests/__data__/expected/.gh-pages/categories/other.m3u b/tests/__data__/expected/.gh-pages/categories/other.m3u new file mode 100644 index 0000000000..58409e132d --- /dev/null +++ b/tests/__data__/expected/.gh-pages/categories/other.m3u @@ -0,0 +1,3 @@ +#EXTM3U x-tvg-url="" +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Other",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/channels.json b/tests/__data__/expected/.gh-pages/channels.json index 56ddad0786..6076b36263 100644 --- a/tests/__data__/expected/.gh-pages/channels.json +++ b/tests/__data__/expected/.gh-pages/channels.json @@ -1 +1 @@ -[{"name":"BBC News HD","logo":"https://i.imgur.com/eNPIQ9f.png","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","categories":[{"name":"News","slug":"news"}],"countries":[{"name":"United Kingdom","code":"UK"}],"languages":[{"name":"English","code":"eng"}],"tvg":{"id":"BBCNews.uk","name":"BBC News HD","url":""}},{"name":"BBC News HD","logo":"https://i.imgur.com/eNPIQ9f.png","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/playlist.m3u8","categories":[{"name":"News","slug":"news"}],"countries":[{"name":"United Kingdom","code":"UK"}],"languages":[{"name":"English","code":"eng"}],"tvg":{"id":"BBCNews.uk","name":"BBC News HD","url":""}},{"name":"Daawah TV","logo":"","url":"http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8","categories":[{"name":"Religious","slug":"religious"}],"countries":[],"languages":[],"tvg":{"id":"","name":"Daawah TV","url":""}},{"name":"Tastemade","logo":"","url":"https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8","categories":[{"name":"Cooking","slug":"cooking"}],"countries":[{"name":"Andorra","code":"AD"},{"name":"Russia","code":"RU"},{"name":"United Kingdom","code":"UK"}],"languages":[],"tvg":{"id":"","name":"Tastemade","url":""}},{"name":"Visit-X TV","logo":"","url":"https://stream.visit-x.tv/vxtv/ngrp:live_all/playlist.m3u8","categories":[{"name":"XXX","slug":"xxx"}],"countries":[],"languages":[],"tvg":{"id":"","name":"Visit-X TV","url":""}},{"name":"ЛДПР ТВ","logo":"https://iptvx.one/icn/ldpr-tv.png","url":"http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8","categories":[{"name":"General","slug":"general"},{"name":"Legislative","slug":"legislative"}],"countries":[{"name":"Russia","code":"RU"}],"languages":[{"name":"Russian","code":"rus"}],"tvg":{"id":"LDPRTV.ru","name":"ЛДПР ТВ","url":"https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml"}}] \ No newline at end of file +[{"name":"BBC News HD","logo":"https://i.imgur.com/eNPIQ9f.png","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","categories":[{"name":"News","slug":"news"}],"countries":[{"name":"United Kingdom","code":"UK"}],"languages":[{"name":"English","code":"eng"}],"tvg":{"id":"BBCNews.uk","name":"BBC News HD","url":""}},{"name":"BBC News HD","logo":"https://i.imgur.com/eNPIQ9f.png","url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/playlist.m3u8","categories":[{"name":"News","slug":"news"}],"countries":[{"name":"United Kingdom","code":"UK"}],"languages":[{"name":"English","code":"eng"}],"tvg":{"id":"BBCNews.uk","name":"BBC News HD","url":""}},{"name":"Daawah TV","logo":"","url":"http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8","categories":[],"countries":[],"languages":[],"tvg":{"id":"","name":"Daawah TV","url":""}},{"name":"Tastemade","logo":"","url":"https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8","categories":[{"name":"Cooking","slug":"cooking"}],"countries":[{"name":"Andorra","code":"AD"},{"name":"Russia","code":"RU"},{"name":"United Kingdom","code":"UK"}],"languages":[],"tvg":{"id":"","name":"Tastemade","url":""}},{"name":"Visit-X TV","logo":"","url":"https://stream.visit-x.tv/vxtv/ngrp:live_all/playlist.m3u8","categories":[{"name":"XXX","slug":"xxx"}],"countries":[],"languages":[],"tvg":{"id":"","name":"Visit-X TV","url":""}},{"name":"ЛДПР ТВ","logo":"https://iptvx.one/icn/ldpr-tv.png","url":"http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8","categories":[{"name":"General","slug":"general"},{"name":"Legislative","slug":"legislative"}],"countries":[{"name":"Russia","code":"RU"}],"languages":[{"name":"Russian","code":"rus"}],"tvg":{"id":"LDPRTV.ru","name":"ЛДПР ТВ","url":"https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml"}}] \ No newline at end of file diff --git a/tests/__data__/expected/.gh-pages/countries/undefined.m3u b/tests/__data__/expected/.gh-pages/countries/undefined.m3u new file mode 100644 index 0000000000..e16261d1d7 --- /dev/null +++ b/tests/__data__/expected/.gh-pages/countries/undefined.m3u @@ -0,0 +1,3 @@ +#EXTM3U x-tvg-url="" +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Undefined",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/index.category.m3u b/tests/__data__/expected/.gh-pages/index.category.m3u index 7323f3127e..05f83ce589 100644 --- a/tests/__data__/expected/.gh-pages/index.category.m3u +++ b/tests/__data__/expected/.gh-pages/index.category.m3u @@ -7,5 +7,5 @@ http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 #EXTINF:-1 tvg-id="BBCNews.uk" tvg-country="UK" tvg-language="English" tvg-logo="https://i.imgur.com/eNPIQ9f.png" group-title="News",BBC News HD (720p) [Not 24/7] http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 -#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Religious",Daawah TV +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Other",Daawah TV http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/index.country.m3u b/tests/__data__/expected/.gh-pages/index.country.m3u index 29c01b82d2..9e8fba4139 100644 --- a/tests/__data__/expected/.gh-pages/index.country.m3u +++ b/tests/__data__/expected/.gh-pages/index.country.m3u @@ -1,6 +1,4 @@ #EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml" -#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="",Daawah TV -http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 #EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Andorra",Tastemade https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 #EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Russia",Tastemade @@ -11,3 +9,5 @@ http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 #EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="United Kingdom",Tastemade https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Undefined",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/index.language.m3u b/tests/__data__/expected/.gh-pages/index.language.m3u index d614536078..c81dfd4f4f 100644 --- a/tests/__data__/expected/.gh-pages/index.language.m3u +++ b/tests/__data__/expected/.gh-pages/index.language.m3u @@ -1,9 +1,9 @@ #EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml" -#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="",Daawah TV -http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 -#EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="",Tastemade -https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 #EXTINF:-1 tvg-id="BBCNews.uk" tvg-country="UK" tvg-language="English" tvg-logo="https://i.imgur.com/eNPIQ9f.png" group-title="English",BBC News HD (720p) [Not 24/7] http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 #EXTINF:-1 tvg-id="LDPRTV.ru" tvg-country="RU" tvg-language="Russian" tvg-logo="https://iptvx.one/icn/ldpr-tv.png" group-title="Russian",ЛДПР ТВ (1080p) http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Undefined",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Undefined",Tastemade +https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/index.m3u b/tests/__data__/expected/.gh-pages/index.m3u index 5f4f07093d..ef512adf63 100644 --- a/tests/__data__/expected/.gh-pages/index.m3u +++ b/tests/__data__/expected/.gh-pages/index.m3u @@ -1,9 +1,9 @@ #EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml" #EXTINF:-1 tvg-id="BBCNews.uk" tvg-country="UK" tvg-language="English" tvg-logo="https://i.imgur.com/eNPIQ9f.png" group-title="News",BBC News HD (720p) [Not 24/7] http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 -#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Religious",Daawah TV -http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 #EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Cooking",Tastemade https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 #EXTINF:-1 tvg-id="LDPRTV.ru" tvg-country="RU" tvg-language="Russian" tvg-logo="https://iptvx.one/icn/ldpr-tv.png" group-title="General;Legislative",ЛДПР ТВ (1080p) http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Other",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/index.nsfw.m3u b/tests/__data__/expected/.gh-pages/index.nsfw.m3u index 54a10dd944..3222ce02b7 100644 --- a/tests/__data__/expected/.gh-pages/index.nsfw.m3u +++ b/tests/__data__/expected/.gh-pages/index.nsfw.m3u @@ -1,11 +1,11 @@ #EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml" #EXTINF:-1 tvg-id="BBCNews.uk" tvg-country="UK" tvg-language="English" tvg-logo="https://i.imgur.com/eNPIQ9f.png" group-title="News",BBC News HD (720p) [Not 24/7] http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 -#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Religious",Daawah TV -http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 #EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Cooking",Tastemade https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 #EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="XXX",Visit-X TV https://stream.visit-x.tv/vxtv/ngrp:live_all/playlist.m3u8 #EXTINF:-1 tvg-id="LDPRTV.ru" tvg-country="RU" tvg-language="Russian" tvg-logo="https://iptvx.one/icn/ldpr-tv.png" group-title="General;Legislative",ЛДПР ТВ (1080p) http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Other",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/index.region.m3u b/tests/__data__/expected/.gh-pages/index.region.m3u index 59a4011ae3..05f2704604 100644 --- a/tests/__data__/expected/.gh-pages/index.region.m3u +++ b/tests/__data__/expected/.gh-pages/index.region.m3u @@ -1,6 +1,4 @@ #EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml" -#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="",Daawah TV -http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 #EXTINF:-1 tvg-id="LDPRTV.ru" tvg-country="RU" tvg-language="Russian" tvg-logo="https://iptvx.one/icn/ldpr-tv.png" group-title="Asia",ЛДПР ТВ (1080p) http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 #EXTINF:-1 tvg-id="LDPRTV.ru" tvg-country="RU" tvg-language="Russian" tvg-logo="https://iptvx.one/icn/ldpr-tv.png" group-title="Commonwealth of Independent States",ЛДПР ТВ (1080p) @@ -15,3 +13,5 @@ http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 #EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Worldwide",Tastemade https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Undefined",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/languages/undefined.m3u b/tests/__data__/expected/.gh-pages/languages/undefined.m3u new file mode 100644 index 0000000000..7ca9967b91 --- /dev/null +++ b/tests/__data__/expected/.gh-pages/languages/undefined.m3u @@ -0,0 +1,5 @@ +#EXTM3U x-tvg-url="" +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Undefined",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 +#EXTINF:-1 tvg-id="" tvg-country="INT" tvg-language="" tvg-logo="" group-title="Undefined",Tastemade +https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8 diff --git a/tests/__data__/expected/.gh-pages/regions/undefined.m3u b/tests/__data__/expected/.gh-pages/regions/undefined.m3u new file mode 100644 index 0000000000..e16261d1d7 --- /dev/null +++ b/tests/__data__/expected/.gh-pages/regions/undefined.m3u @@ -0,0 +1,3 @@ +#EXTM3U x-tvg-url="" +#EXTINF:-1 tvg-id="" tvg-country="" tvg-language="" tvg-logo="" group-title="Undefined",Daawah TV +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 diff --git a/tests/__data__/expected/logs/generate-playlists/categories.log b/tests/__data__/expected/logs/generate-playlists/categories.log index 5a8d3cbac6..feeadad3fb 100644 --- a/tests/__data__/expected/logs/generate-playlists/categories.log +++ b/tests/__data__/expected/logs/generate-playlists/categories.log @@ -2,6 +2,5 @@ {"name":"General","slug":"general","count":1} {"name":"Legislative","slug":"legislative","count":1} {"name":"News","slug":"news","count":1} -{"name":"Religious","slug":"religious","count":1} {"name":"XXX","slug":"xxx","count":1} -{"name":"Other","slug":"other","count":0} +{"name":"Other","slug":"other","count":1} diff --git a/tests/__data__/input/generate-playlists.test.db b/tests/__data__/input/generate-playlists.test.db index e8701485c9..46b45e560d 100644 --- a/tests/__data__/input/generate-playlists.test.db +++ b/tests/__data__/input/generate-playlists.test.db @@ -5,4 +5,4 @@ {"name":"BBC News HD","id":"AndorraTV.ad","filepath":"tests/__data__/output/channels/uk.m3u","src_country":{"name":"United Kingdom","code":"UK","lang":"eng"},"tvg_country":"UK","countries":[{"name":"United Kingdom","code":"UK","lang":"eng"}],"regions":[{"name":"Europe, the Middle East and Africa","code":"EMEA"},{"name":"Europe","code":"EUR"}],"languages":[{"name":"English","code":"eng"}],"categories":[{"name":"News","slug":"news","nsfw":false}],"tvg_url":"","guides":[],"logo":"https://i.imgur.com/eNPIQ9f.png","resolution":{"height":720,"width":null},"status":{"label":"Not 24/7","code":"not_247","level":3},"url":"http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8","http":{"referrer":"","user-agent":""},"is_nsfw":false,"is_broken":false,"updated":false,"cluster_id":3,"_id":"WTbieV1ptnZVCIdn"} {"name":"Visit-X TV","id":"","filepath":"tests/__data__/output/channels/nl.m3u","src_country":{},"tvg_country":"","countries":[],"regions":[],"languages":[],"categories":[{"name":"XXX","slug":"xxx","nsfw":true}],"tvg_url":"","guides":[],"logo":"","resolution":{},"status":{"label":"","code":"online","level":1},"url":"https://stream.visit-x.tv/vxtv/ngrp:live_all/playlist.m3u8","http":{"referrer":"","user-agent":""},"is_nsfw":true,"is_broken":false,"updated":false,"cluster_id":1,"_id":"2ST8btby3mmsgPF5"} {"name":"Tastemade","id":"","filepath":"tests/__data__/output/channels/qa.m3u","src_country":{},"tvg_country":"INT","countries":[{"name":"Andorra","code":"AD","lang":"cat"},{"name":"Russia","code":"RU","lang":"rus"},{"name":"United Kingdom","code":"UK","lang":"eng"}],"regions":[{"name":"Worldwide","code":"INT"}],"languages":[],"categories":[{"name":"Cooking","slug":"cooking","nsfw":false}],"tvg_url":"","guides":[],"logo":"","resolution":{},"status":{"label":"","code":"online","level":1},"url":"https://tastemade-freetv16min-plex.amagi.tv/hls/amagi_hls_data_tastemade-tastemadefreetv16-plex/CDN/playlist.m3u8","http":{"referrer":"","user-agent":""},"is_nsfw":false,"is_broken":false,"updated":false,"cluster_id":1,"_id":"2ST8btby3mmsgPAB"} -{"name":"Daawah TV","id":"","filepath":"tests/__data__/output/channels/in.m3u","src_country":{},"tvg_country":"","countries":[],"regions":[],"languages":[],"categories":[{"name":"Religious","slug":"religious","nsfw":false}],"tvg_url":"","guides":[],"logo":"","resolution":{},"status":{"label":"","code":"online","level":1},"url":"http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8","http":{"referrer":"","user-agent":""},"is_nsfw":false,"is_broken":false,"updated":false,"cluster_id":1,"_id":"2ST8btby3mmsgPF9"} +{"name":"Daawah TV","id":"","filepath":"tests/__data__/output/channels/in.m3u","src_country":{},"tvg_country":"","countries":[],"regions":[],"languages":[],"categories":[],"tvg_url":"","guides":[],"logo":"","resolution":{},"status":{"label":"","code":"online","level":1},"url":"http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8","http":{"referrer":"","user-agent":""},"is_nsfw":false,"is_broken":false,"updated":false,"cluster_id":1,"_id":"2ST8btby3mmsgPF9"} diff --git a/tests/commands/generate-playlists.test.js b/tests/commands/generate-playlists.test.js index f53aedf04f..0b5a12a08e 100644 --- a/tests/commands/generate-playlists.test.js +++ b/tests/commands/generate-playlists.test.js @@ -24,100 +24,137 @@ afterEach(() => { }) it('can generate categories', () => { - expect(content('output/.gh-pages/categories/general.m3u')) - .toBe(content('expected/.gh-pages/categories/general.m3u')) + expect(content('output/.gh-pages/categories/general.m3u')).toBe( + content('expected/.gh-pages/categories/general.m3u') + ) - expect(content('output/.gh-pages/categories/legislative.m3u')) - .toBe(content('expected/.gh-pages/categories/legislative.m3u')) + expect(content('output/.gh-pages/categories/legislative.m3u')).toBe( + content('expected/.gh-pages/categories/legislative.m3u') + ) - expect(content('output/.gh-pages/categories/news.m3u')) - .toBe(content('expected/.gh-pages/categories/news.m3u')) + expect(content('output/.gh-pages/categories/news.m3u')).toBe( + content('expected/.gh-pages/categories/news.m3u') + ) + + expect(content('output/.gh-pages/categories/other.m3u')).toBe( + content('expected/.gh-pages/categories/other.m3u') + ) }) it('can generate countries', () => { - expect(content('output/.gh-pages/countries/ru.m3u')) - .toBe(content('expected/.gh-pages/countries/ru.m3u')) + expect(content('output/.gh-pages/countries/ru.m3u')).toBe( + content('expected/.gh-pages/countries/ru.m3u') + ) - expect(content('output/.gh-pages/countries/uk.m3u')) - .toBe(content('expected/.gh-pages/countries/uk.m3u')) + expect(content('output/.gh-pages/countries/uk.m3u')).toBe( + content('expected/.gh-pages/countries/uk.m3u') + ) + + expect(content('output/.gh-pages/countries/undefined.m3u')).toBe( + content('expected/.gh-pages/countries/undefined.m3u') + ) }) it('can generate languages', () => { - expect(content('output/.gh-pages/languages/rus.m3u')) - .toBe(content('expected/.gh-pages/languages/rus.m3u')) + expect(content('output/.gh-pages/languages/rus.m3u')).toBe( + content('expected/.gh-pages/languages/rus.m3u') + ) - expect(content('output/.gh-pages/languages/eng.m3u')) - .toBe(content('expected/.gh-pages/languages/eng.m3u')) + expect(content('output/.gh-pages/languages/eng.m3u')).toBe( + content('expected/.gh-pages/languages/eng.m3u') + ) + + expect(content('output/.gh-pages/languages/undefined.m3u')).toBe( + content('expected/.gh-pages/languages/undefined.m3u') + ) }) it('can generate regions', () => { - expect(content('output/.gh-pages/regions/asia.m3u')) - .toBe(content('expected/.gh-pages/regions/asia.m3u')) + expect(content('output/.gh-pages/regions/asia.m3u')).toBe( + content('expected/.gh-pages/regions/asia.m3u') + ) - expect(content('output/.gh-pages/regions/cis.m3u')) - .toBe(content('expected/.gh-pages/regions/cis.m3u')) + expect(content('output/.gh-pages/regions/cis.m3u')).toBe( + content('expected/.gh-pages/regions/cis.m3u') + ) - expect(content('output/.gh-pages/regions/emea.m3u')) - .toBe(content('expected/.gh-pages/regions/emea.m3u')) + expect(content('output/.gh-pages/regions/emea.m3u')).toBe( + content('expected/.gh-pages/regions/emea.m3u') + ) - expect(content('output/.gh-pages/regions/eur.m3u')) - .toBe(content('expected/.gh-pages/regions/eur.m3u')) + expect(content('output/.gh-pages/regions/eur.m3u')).toBe( + content('expected/.gh-pages/regions/eur.m3u') + ) - expect(content('output/.gh-pages/regions/int.m3u')) - .toBe(content('expected/.gh-pages/regions/int.m3u')) + expect(content('output/.gh-pages/regions/int.m3u')).toBe( + content('expected/.gh-pages/regions/int.m3u') + ) + + expect(content('output/.gh-pages/regions/undefined.m3u')).toBe( + content('expected/.gh-pages/regions/undefined.m3u') + ) }) it('can generate channels.json', () => { - expect(content('output/.gh-pages/channels.json')) - .toBe(content('expected/.gh-pages/channels.json')) + expect(content('output/.gh-pages/channels.json')).toBe( + content('expected/.gh-pages/channels.json') + ) }) it('can generate index.category.m3u', () => { - expect(content('output/.gh-pages/index.category.m3u')) - .toBe(content('expected/.gh-pages/index.category.m3u')) + expect(content('output/.gh-pages/index.category.m3u')).toBe( + content('expected/.gh-pages/index.category.m3u') + ) }) it('can generate index.country.m3u', () => { - expect(content('output/.gh-pages/index.country.m3u')) - .toBe(content('expected/.gh-pages/index.country.m3u')) + expect(content('output/.gh-pages/index.country.m3u')).toBe( + content('expected/.gh-pages/index.country.m3u') + ) }) it('can generate index.language.m3u', () => { - expect(content('output/.gh-pages/index.language.m3u')) - .toBe(content('expected/.gh-pages/index.language.m3u')) + expect(content('output/.gh-pages/index.language.m3u')).toBe( + content('expected/.gh-pages/index.language.m3u') + ) }) it('can generate index.region.m3u', () => { - expect(content('output/.gh-pages/index.region.m3u')) - .toBe(content('expected/.gh-pages/index.region.m3u')) + expect(content('output/.gh-pages/index.region.m3u')).toBe( + content('expected/.gh-pages/index.region.m3u') + ) }) it('can generate index.m3u', () => { - expect(content('output/.gh-pages/index.m3u')) - .toBe(content('expected/.gh-pages/index.m3u')) + expect(content('output/.gh-pages/index.m3u')).toBe(content('expected/.gh-pages/index.m3u')) }) it('can generate index.nsfw.m3u', () => { - expect(content('output/.gh-pages/index.nsfw.m3u')) - .toBe(content('expected/.gh-pages/index.nsfw.m3u')) + expect(content('output/.gh-pages/index.nsfw.m3u')).toBe( + content('expected/.gh-pages/index.nsfw.m3u') + ) }) it('can generate logs categories', () => { - expect(content('output/logs/generate-playlists/categories.log')) - .toBe(content('expected/logs/generate-playlists/categories.log')) + expect(content('output/logs/generate-playlists/categories.log')).toBe( + content('expected/logs/generate-playlists/categories.log') + ) }) it('can generate logs countries', () => { - expect(content('output/logs/generate-playlists/countries.log')) - .toBe(content('expected/logs/generate-playlists/countries.log')) + expect(content('output/logs/generate-playlists/countries.log')).toBe( + content('expected/logs/generate-playlists/countries.log') + ) }) it('can generate logs languages', () => { - expect(content('output/logs/generate-playlists/languages.log')) - .toBe(content('expected/logs/generate-playlists/languages.log')) + expect(content('output/logs/generate-playlists/languages.log')).toBe( + content('expected/logs/generate-playlists/languages.log') + ) }) it('can generate logs regions', () => { - expect(content('output/logs/generate-playlists/regions.log')) - .toBe(content('expected/logs/generate-playlists/regions.log')) + expect(content('output/logs/generate-playlists/regions.log')).toBe( + content('expected/logs/generate-playlists/regions.log') + ) })