Update update-readme.js
This commit is contained in:
parent
e07540757d
commit
ea60c96416
|
@ -3,7 +3,7 @@ const ISO6391 = require('iso-639-1')
|
||||||
const markdownInclude = require('markdown-include')
|
const markdownInclude = require('markdown-include')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
let data = {
|
let output = {
|
||||||
countries: [],
|
countries: [],
|
||||||
languages: [],
|
languages: [],
|
||||||
categories: []
|
categories: []
|
||||||
|
@ -33,7 +33,7 @@ function parseIndex() {
|
||||||
const countryCode = util.getBasename(rootItem.url).toUpperCase()
|
const countryCode = util.getBasename(rootItem.url).toUpperCase()
|
||||||
const epg = playlist.header.attrs['x-tvg-url'] ? `<code>${playlist.header.attrs['x-tvg-url']}</code>` : ''
|
const epg = playlist.header.attrs['x-tvg-url'] ? `<code>${playlist.header.attrs['x-tvg-url']}</code>` : ''
|
||||||
|
|
||||||
data.countries.push({
|
output.countries.push({
|
||||||
country: rootItem.name,
|
country: rootItem.name,
|
||||||
channels: playlist.items.length,
|
channels: playlist.items.length,
|
||||||
playlist: `<code>https://iptv-org.github.io/iptv/${rootItem.url}</code>`,
|
playlist: `<code>https://iptv-org.github.io/iptv/${rootItem.url}</code>`,
|
||||||
|
@ -42,7 +42,7 @@ function parseIndex() {
|
||||||
|
|
||||||
for(let item of playlist.items) {
|
for(let item of playlist.items) {
|
||||||
// language
|
// language
|
||||||
const languageName = item.group.title || 'Undefined'
|
const languageName = item.tvg.language || 'Undefined'
|
||||||
const languageCode = ISO6391.getCode(languageName) || 'undefined'
|
const languageCode = ISO6391.getCode(languageName) || 'undefined'
|
||||||
if(languages[languageCode]) {
|
if(languages[languageCode]) {
|
||||||
languages[languageCode].channels++
|
languages[languageCode].channels++
|
||||||
|
@ -69,12 +69,12 @@ function parseIndex() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.languages = Object.values(languages)
|
output.languages = Object.values(languages)
|
||||||
data.categories = Object.values(categories)
|
output.categories = Object.values(categories)
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateCountriesTable() {
|
function generateCountriesTable() {
|
||||||
const table = util.generateTable(data.countries, {
|
const table = util.generateTable(output.countries, {
|
||||||
columns: [
|
columns: [
|
||||||
{ name: 'Country', align: 'left' },
|
{ name: 'Country', align: 'left' },
|
||||||
{ name: 'Channels', align: 'right' },
|
{ name: 'Channels', align: 'right' },
|
||||||
|
@ -87,7 +87,7 @@ function generateCountriesTable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateLanguagesTable() {
|
function generateLanguagesTable() {
|
||||||
data.languages.sort((a, b) => {
|
output.languages.sort((a, b) => {
|
||||||
if(a.language === 'Undefined') { return 1 }
|
if(a.language === 'Undefined') { return 1 }
|
||||||
if(b.language === 'Undefined') { return -1 }
|
if(b.language === 'Undefined') { return -1 }
|
||||||
if(a.language < b.language) { return -1 }
|
if(a.language < b.language) { return -1 }
|
||||||
|
@ -95,7 +95,7 @@ function generateLanguagesTable() {
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
const table = util.generateTable(data.languages, {
|
const table = util.generateTable(output.languages, {
|
||||||
columns: [
|
columns: [
|
||||||
{ name: 'Language', align: 'left' },
|
{ name: 'Language', align: 'left' },
|
||||||
{ name: 'Channels', align: 'right' },
|
{ name: 'Channels', align: 'right' },
|
||||||
|
@ -107,7 +107,7 @@ function generateLanguagesTable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateCategoriesTable() {
|
function generateCategoriesTable() {
|
||||||
data.categories.sort((a, b) => {
|
output.categories.sort((a, b) => {
|
||||||
if(a.category === 'Other') { return 1 }
|
if(a.category === 'Other') { return 1 }
|
||||||
if(b.category === 'Other') { return -1 }
|
if(b.category === 'Other') { return -1 }
|
||||||
if(a.category < b.category) { return -1 }
|
if(a.category < b.category) { return -1 }
|
||||||
|
@ -115,7 +115,7 @@ function generateCategoriesTable() {
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
const table = util.generateTable(data.categories, {
|
const table = util.generateTable(output.categories, {
|
||||||
columns: [
|
columns: [
|
||||||
{ name: 'Category', align: 'left' },
|
{ name: 'Category', align: 'left' },
|
||||||
{ name: 'Channels', align: 'right' },
|
{ name: 'Channels', align: 'right' },
|
||||||
|
|
Loading…
Reference in New Issue