diff --git a/scripts/update-readme.js b/scripts/update-readme.js
index b64d6ab445..c1a3faa4e1 100644
--- a/scripts/update-readme.js
+++ b/scripts/update-readme.js
@@ -1,5 +1,6 @@
const utils = require('./utils')
const db = require('./db')
+const parser = require('./parser')
db.load()
@@ -14,22 +15,16 @@ function main() {
function generateCategoriesTable() {
console.log(`Generating categories table...`)
- const categories = []
- for (const category of db.categories.all()) {
+ const categories = []
+ for (const category of [...db.categories.all(), { name: 'Other', id: 'other' }]) {
categories.push({
category: category.name,
- channels: db.channels.forCategory(category).count(),
+ channels: db.channels.forCategory(category).removeDuplicates().count(),
playlist: `https://iptv-org.github.io/iptv/categories/${category.id}.m3u
`
})
}
- categories.push({
- category: 'Other',
- channels: db.channels.forCategory({ id: 'other' }).count(),
- playlist: `https://iptv-org.github.io/iptv/categories/other.m3u
`
- })
-
const table = utils.generateTable(categories, {
columns: [
{ name: 'Category', align: 'left' },
@@ -43,23 +38,21 @@ function generateCategoriesTable() {
function generateCountriesTable() {
console.log(`Generating countries table...`)
- const countries = []
- for (const country of db.countries.sortBy(['name']).all()) {
+ const countries = []
+ for (const country of [
+ ...db.countries.sortBy(['name']).all(),
+ { name: 'Undefined', code: 'undefined' }
+ ]) {
let flag = utils.code2flag(country.code)
+ const prefix = flag ? `${flag} ` : ''
countries.push({
- country: flag + ' ' + country.name,
- channels: db.channels.forCountry(country).count(),
+ country: prefix + country.name,
+ channels: db.channels.forCountry(country).removeDuplicates().count(),
playlist: `https://iptv-org.github.io/iptv/countries/${country.code}.m3u
`
})
}
- countries.push({
- country: 'Undefined',
- channels: db.channels.forCountry({ code: 'undefined' }).count(),
- playlist: `https://iptv-org.github.io/iptv/countries/undefined.m3u
`
- })
-
const table = utils.generateTable(countries, {
columns: [
{ name: 'Country', align: 'left' },
@@ -75,20 +68,17 @@ function generateLanguagesTable() {
console.log(`Generating languages table...`)
const languages = []
- for (const language of db.languages.sortBy(['name']).all()) {
+ for (const language of [
+ ...db.languages.sortBy(['name']).all(),
+ { name: 'Undefined', code: 'undefined' }
+ ]) {
languages.push({
language: language.name,
- channels: db.channels.forLanguage(language).count(),
+ channels: db.channels.forLanguage(language).removeDuplicates().count(),
playlist: `https://iptv-org.github.io/iptv/languages/${language.code}.m3u
`
})
}
- languages.push({
- language: 'Undefined',
- channels: db.channels.forLanguage({ code: 'undefined' }).count(),
- playlist: `https://iptv-org.github.io/iptv/languages/undefined.m3u
`
- })
-
const table = utils.generateTable(languages, {
columns: [
{ name: 'Language', align: 'left' },