diff --git a/scripts/update-readme.js b/scripts/update-readme.js index ac4f9a8b38..697b974d82 100644 --- a/scripts/update-readme.js +++ b/scripts/update-readme.js @@ -23,23 +23,29 @@ function main() { function parseIndex() { const root = helper.parsePlaylist('index.m3u') + let countries = {} let languages = {} let categories = {} for(let rootItem of root.items) { const playlist = helper.parsePlaylist(rootItem.url) - const countryCode = helper.getBasename(rootItem.url).toUpperCase() - const epg = playlist.header.attrs['x-tvg-url'] ? `${playlist.header.attrs['x-tvg-url']}` : '' - - // country - output.countries.push({ - country: rootItem.name, - channels: playlist.items.length, - playlist: `https://iptv-org.github.io/iptv/${rootItem.url}`, - epg - }) + const countryName = rootItem.name + const countryCode = helper.getBasename(rootItem.url).toLowerCase() + const countryEpg = playlist.header.attrs['x-tvg-url'] ? `${playlist.header.attrs['x-tvg-url']}` : '' for(let item of playlist.items) { + // country + if(countries[countryCode]) { + countries[countryCode].channels++ + } else { + countries[countryCode] = { + country: countryName, + channels: playlist.items.length, + playlist: `https://iptv-org.github.io/iptv/countries/${countryCode}.m3u`, + epg: countryEpg + } + } + // language const languageName = item.tvg.language || 'Undefined' const languageCode = helper.getISO6391Code(languageName) || 'undefined' @@ -68,6 +74,7 @@ function parseIndex() { } } + output.countries = Object.values(countries) output.languages = Object.values(languages) output.categories = Object.values(categories) }