Update update-readme.js

This commit is contained in:
freearhey 2021-05-10 16:25:23 +03:00
parent d99372e552
commit 732b131e9b
1 changed files with 17 additions and 27 deletions

View File

@ -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: `<code>https://iptv-org.github.io/iptv/categories/${category.id}.m3u</code>`
})
}
categories.push({
category: 'Other',
channels: db.channels.forCategory({ id: 'other' }).count(),
playlist: `<code>https://iptv-org.github.io/iptv/categories/other.m3u</code>`
})
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}&nbsp;` : ''
countries.push({
country: flag + '&nbsp;' + country.name,
channels: db.channels.forCountry(country).count(),
country: prefix + country.name,
channels: db.channels.forCountry(country).removeDuplicates().count(),
playlist: `<code>https://iptv-org.github.io/iptv/countries/${country.code}.m3u</code>`
})
}
countries.push({
country: 'Undefined',
channels: db.channels.forCountry({ code: 'undefined' }).count(),
playlist: `<code>https://iptv-org.github.io/iptv/countries/undefined.m3u</code>`
})
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: `<code>https://iptv-org.github.io/iptv/languages/${language.code}.m3u</code>`
})
}
languages.push({
language: 'Undefined',
channels: db.channels.forLanguage({ code: 'undefined' }).count(),
playlist: `<code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code>`
})
const table = utils.generateTable(languages, {
columns: [
{ name: 'Language', align: 'left' },