Update update-readme.js

This commit is contained in:
freearhey 2021-01-31 20:19:01 +03:00
parent 9a96aaa4fe
commit ded70c18b9

View File

@ -1,10 +1,11 @@
const utils = require('./utils') const utils = require('./utils')
const parser = require('./parser') const parser = require('./parser')
const categories = require('./categories')
const list = { const list = {
countries: [], countries: {},
languages: [], languages: {},
categories: [] categories: {}
} }
function main() { function main() {
@ -20,11 +21,7 @@ function parseIndex() {
console.log(`Parsing index...`) console.log(`Parsing index...`)
const items = parser.parseIndex() const items = parser.parseIndex()
const countries = {} list.countries['undefined'] = {
const languages = {}
const categories = {}
countries['undefined'] = {
country: 'Undefined', country: 'Undefined',
channels: 0, channels: 0,
playlist: `<code>https://iptv-org.github.io/iptv/countries/undefined.m3u</code>`, playlist: `<code>https://iptv-org.github.io/iptv/countries/undefined.m3u</code>`,
@ -32,20 +29,20 @@ function parseIndex() {
name: 'Undefined' name: 'Undefined'
} }
languages['undefined'] = { list.languages['undefined'] = {
language: 'Undefined', language: 'Undefined',
channels: 0, channels: 0,
playlist: `<code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code>` playlist: `<code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code>`
} }
for (const category of utils.supportedCategories) { for (const category of categories) {
categories[category.id] = { list.categories[category.id] = {
category: category.name, category: category.name,
channels: 0, channels: 0,
playlist: `<code>https://iptv-org.github.io/iptv/categories/${category.id}.m3u</code>` playlist: `<code>https://iptv-org.github.io/iptv/categories/${category.id}.m3u</code>`
} }
} }
categories['other'] = { list.categories['other'] = {
category: 'Other', category: 'Other',
channels: 0, channels: 0,
playlist: `<code>https://iptv-org.github.io/iptv/categories/other.m3u</code>` playlist: `<code>https://iptv-org.github.io/iptv/categories/other.m3u</code>`
@ -56,14 +53,14 @@ function parseIndex() {
for (let channel of playlist.channels) { for (let channel of playlist.channels) {
// countries // countries
if (!channel.countries.length) { if (!channel.countries.length) {
countries['undefined'].channels++ list.countries['undefined'].channels++
} else { } else {
for (let country of channel.countries) { for (let country of channel.countries) {
if (countries[country.code]) { if (list.countries[country.code]) {
countries[country.code].channels++ list.countries[country.code].channels++
} else { } else {
let flag = utils.code2flag(country.code) let flag = utils.code2flag(country.code)
countries[country.code] = { list.countries[country.code] = {
country: flag + '&nbsp;' + country.name, country: flag + '&nbsp;' + country.name,
channels: 1, channels: 1,
playlist: `<code>https://iptv-org.github.io/iptv/countries/${country.code}.m3u</code>`, playlist: `<code>https://iptv-org.github.io/iptv/countries/${country.code}.m3u</code>`,
@ -78,13 +75,13 @@ function parseIndex() {
// languages // languages
if (!channel.languages.length) { if (!channel.languages.length) {
languages['undefined'].channels++ list.languages['undefined'].channels++
} else { } else {
for (let language of channel.languages) { for (let language of channel.languages) {
if (languages[language.code]) { if (list.languages[language.code]) {
languages[language.code].channels++ list.languages[language.code].channels++
} else { } else {
languages[language.code] = { list.languages[language.code] = {
language: language.name, language: language.name,
channels: 1, channels: 1,
playlist: `<code>https://iptv-org.github.io/iptv/languages/${language.code}.m3u</code>` playlist: `<code>https://iptv-org.github.io/iptv/languages/${language.code}.m3u</code>`
@ -96,16 +93,16 @@ function parseIndex() {
// categories // categories
const categoryId = channel.category.toLowerCase() const categoryId = channel.category.toLowerCase()
if (!categoryId) { if (!categoryId) {
categories['other'].channels++ list.categories['other'].channels++
} else if (categories[categoryId]) { } else if (list.categories[categoryId]) {
categories[categoryId].channels++ list.categories[categoryId].channels++
} }
} }
} }
list.countries = Object.values(countries) list.countries = Object.values(list.countries)
list.languages = Object.values(languages) list.languages = Object.values(list.languages)
list.categories = Object.values(categories) list.categories = Object.values(list.categories)
} }
function generateCountriesTable() { function generateCountriesTable() {