From ab864419693ac0bd5426a6b53f0d4de6a65aeeb6 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 1 Jan 2022 12:06:58 +0300 Subject: [PATCH] Fixes grouping issue (#5929) --- scripts/commands/generate-playlists.js | 3 ++ .../__data__/input/generate-playlists.test.db | 2 + tests/commands/generate-playlists.test.js | 38 ++++++++++++++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/scripts/commands/generate-playlists.js b/scripts/commands/generate-playlists.js index c82442ca6e..3ea4abed9a 100644 --- a/scripts/commands/generate-playlists.js +++ b/scripts/commands/generate-playlists.js @@ -219,6 +219,7 @@ async function generateIndexCountry() { .map(item => { const newItem = _.cloneDeep(item) newItem.group_title = '' + newItem.categories = [] return newItem }) for (const country of _.sortBy(Object.values(countries), ['name'])) { @@ -254,6 +255,7 @@ async function generateIndexLanguage() { .map(item => { const newItem = _.cloneDeep(item) newItem.group_title = '' + newItem.categories = [] return newItem }) for (const language of languages) { @@ -289,6 +291,7 @@ async function generateIndexRegion() { .map(item => { const newItem = _.cloneDeep(item) newItem.group_title = '' + newItem.categories = [] return newItem }) for (const region of regions) { diff --git a/tests/__data__/input/generate-playlists.test.db b/tests/__data__/input/generate-playlists.test.db index eb053f58de..4212ad0d4d 100644 --- a/tests/__data__/input/generate-playlists.test.db +++ b/tests/__data__/input/generate-playlists.test.db @@ -3,3 +3,5 @@ {"name":"ATV","id":"AndorraTV.ad","filepath":"tests/__data__/output/channels/ad.m3u","src_country":{"name":"Andorra","code":"AD","lang":"cat"},"tvg_country":"AD","countries":[{"name":"Andorra","code":"AD","lang":"cat"}],"regions":[{"name":"Europe, the Middle East and Africa","code":"EMEA"},{"name":"Europe","code":"EUR"}],"languages":[{"name":"Catalan","code":"cat"}],"categories":[{"name":"General","slug":"general","nsfw":false}],"tvg_url":"","guides":[],"logo":"https://i.imgur.com/kJCjeQ4.png","resolution":{"height":720,"width":null},"status":{"label":"Offline","code":"offline","level":5},"url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http":{"referrer":"","user-agent":""},"is_nsfw":false,"is_broken":true,"updated":false,"cluster_id":1,"_id":"I6cjG2xCBRFFP4sz"} {"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":[],"regions":[],"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"} diff --git a/tests/commands/generate-playlists.test.js b/tests/commands/generate-playlists.test.js index 9772bdf02f..d3edfd8cd4 100644 --- a/tests/commands/generate-playlists.test.js +++ b/tests/commands/generate-playlists.test.js @@ -100,25 +100,33 @@ http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 it('can generate channels.json', () => { expect(content('.gh-pages/channels.json')).toBe( - `[{"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":"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"}}]` + `[{"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":"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":[],"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"}}]` ) }) it('can generate index.category.m3u', () => { expect(content('.gh-pages/index.category.m3u')) .toBe(`#EXTM3U x-tvg-url="https://iptv-org.github.io/epg/guides/ru/tv.yandex.ru.epg.xml" +#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",ЛДПР ТВ (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="Legislative",ЛДПР ТВ (1080p) 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 +http://51.15.246.58:8081/daawahtv/daawahtv2/playlist.m3u8 `) }) it('can generate index.country.m3u', () => { expect(content('.gh-pages/index.country.m3u')) .toBe(`#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="LDPRTV.ru" tvg-country="RU" tvg-language="Russian" tvg-logo="https://iptvx.one/icn/ldpr-tv.png" group-title="Russia",ЛДПР ТВ (1080p) 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="United Kingdom",BBC News HD (720p) [Not 24/7] @@ -129,6 +137,10 @@ http://1111296894.rsc.cdn77.org/LS-ATL-54548-6/index.m3u8 it('can generate index.language.m3u', () => { expect(content('.gh-pages/index.language.m3u')) .toBe(`#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) @@ -139,6 +151,10 @@ http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 it('can generate index.region.m3u', () => { expect(content('.gh-pages/index.region.m3u')) .toBe(`#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="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) @@ -159,6 +175,10 @@ it('can generate index.m3u', () => { .toBe(`#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 `) @@ -169,6 +189,10 @@ it('can generate index.nsfw.m3u', () => { .toBe(`#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) @@ -178,9 +202,11 @@ http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8 it('can generate logs categories', () => { expect(content('logs/generate-playlists/categories.log')) - .toBe(`{"name":"General","slug":"general","count":1} + .toBe(`{"name":"Cooking","slug":"cooking","count":1} +{"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} `) @@ -191,8 +217,8 @@ it('can generate logs countries', () => { .toBe(`{"name":"Andorra","code":"AD","count":0} {"name":"Russia","code":"RU","count":1} {"name":"United Kingdom","code":"UK","count":1} -{"name":"International","code":"INT","count":0} -{"name":"Undefined","code":"UNDEFINED","count":0} +{"name":"International","code":"INT","count":1} +{"name":"Undefined","code":"UNDEFINED","count":2} `) }) @@ -201,7 +227,7 @@ it('can generate logs languages', () => { .toBe(`{"name":"Catalan","code":"cat","count":0} {"name":"English","code":"eng","count":1} {"name":"Russian","code":"rus","count":1} -{"name":"Undefined","code":"undefined","count":0} +{"name":"Undefined","code":"undefined","count":2} `) }) @@ -211,6 +237,6 @@ it('can generate logs regions', () => { {"name":"Commonwealth of Independent States","code":"CIS","count":1} {"name":"Europe","code":"EUR","count":2} {"name":"Europe, the Middle East and Africa","code":"EMEA","count":2} -{"name":"Undefined","code":"UNDEFINED","count":0} +{"name":"Undefined","code":"UNDEFINED","count":2} `) })