Update update-readme.js
This commit is contained in:
parent
3e770c7c78
commit
c6d0ad66bb
|
@ -1,17 +1,14 @@
|
||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
const ISO6391 = require('iso-639-1')
|
const ISO6391 = require('iso-639-1')
|
||||||
|
const markdownInclude = require('markdown-include')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
const debug = false
|
|
||||||
const categories = util.supportedCategories.map(c => c.toLowerCase())
|
|
||||||
let stats = {
|
|
||||||
countries: 0,
|
|
||||||
channels: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
let languageBuffer = {
|
let languageBuffer = {
|
||||||
undefined: []
|
undefined: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let categories = util.supportedCategories.map(c => c.toLowerCase())
|
||||||
let categoryBuffer = {}
|
let categoryBuffer = {}
|
||||||
categories.push('other')
|
categories.push('other')
|
||||||
categories.forEach(category => {
|
categories.forEach(category => {
|
||||||
|
@ -28,29 +25,29 @@ function main() {
|
||||||
console.log(`Parsing 'index.m3u'...`)
|
console.log(`Parsing 'index.m3u'...`)
|
||||||
const playlist = util.parsePlaylist('index.m3u')
|
const playlist = util.parsePlaylist('index.m3u')
|
||||||
let countries = playlist.items
|
let countries = playlist.items
|
||||||
if(debug) {
|
|
||||||
console.log('Debug mode is turn on')
|
|
||||||
countries = countries.slice(0, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
for(let category of categories) {
|
for(let category of categories) {
|
||||||
const filename = `categories/${category}.m3u`
|
const filename = `categories/${category}.m3u`
|
||||||
const categoryName = util.supportedCategories.find(c => c.toLowerCase() === category) || 'Other'
|
const categoryName = util.supportedCategories.find(c => c.toLowerCase() === category) || 'Other'
|
||||||
repo.categories[category] = { category: categoryName, channels: 0, playlist: `<code>https://iptv-org.github.io/iptv/${filename}</code>` }
|
repo.categories[category] = {
|
||||||
|
category: categoryName,
|
||||||
|
channels: 0,
|
||||||
|
playlist: `<code>https://iptv-org.github.io/iptv/${filename}</code>`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let country of countries) {
|
for(let country of countries) {
|
||||||
console.log(`Parsing '${country.url}'...`)
|
console.log(`Parsing '${country.url}'...`)
|
||||||
const playlist = util.parsePlaylist(country.url)
|
const playlist = util.parsePlaylist(country.url)
|
||||||
|
|
||||||
const c = {
|
const countryCode = util.getBasename(country.url).toUpperCase()
|
||||||
name: country.name,
|
repo.countries[countryCode] = {
|
||||||
code: util.getBasename(country.url).toUpperCase()
|
country: country.name,
|
||||||
|
channels: playlist.items.length,
|
||||||
|
playlist: `<code>https://iptv-org.github.io/iptv/${country.url}</code>`,
|
||||||
|
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>` : ''
|
|
||||||
repo.countries[c.code] = { country: c.name, channels: playlist.items.length, playlist: `<code>https://iptv-org.github.io/iptv/${country.url}</code>`, epg }
|
|
||||||
|
|
||||||
for(let item of playlist.items) {
|
for(let item of playlist.items) {
|
||||||
|
|
||||||
let channel = util.createChannel(item)
|
let channel = util.createChannel(item)
|
||||||
|
@ -72,20 +69,25 @@ function main() {
|
||||||
} else {
|
} else {
|
||||||
languageBuffer['undefined'].push(channel)
|
languageBuffer['undefined'].push(channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.channels++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.countries++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const languageCode in languageBuffer) {
|
for(const languageCode in languageBuffer) {
|
||||||
let languageName = ISO6391.getName(languageCode)
|
let languageName = ISO6391.getName(languageCode)
|
||||||
if(languageName) {
|
if(languageName) {
|
||||||
repo.languages[languageCode] = { language: languageName, channels: 0, playlist: `<code>https://iptv-org.github.io/iptv/languages/${languageCode}.m3u</code>` }
|
repo.languages[languageCode] = {
|
||||||
|
language: languageName,
|
||||||
|
channels: 0,
|
||||||
|
playlist: `<code>https://iptv-org.github.io/iptv/languages/${languageCode}.m3u</code>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repo.languages['undefined'] = { language: 'Undefined', channels: 0, playlist: `<code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code>` }
|
}
|
||||||
|
|
||||||
|
repo.languages['undefined'] = {
|
||||||
|
language: 'Undefined',
|
||||||
|
channels: 0,
|
||||||
|
playlist: `<code>https://iptv-org.github.io/iptv/languages/undefined.m3u</code>`
|
||||||
|
}
|
||||||
|
|
||||||
util.clearCache()
|
util.clearCache()
|
||||||
for(const languageCode in languageBuffer) {
|
for(const languageCode in languageBuffer) {
|
||||||
|
@ -145,8 +147,10 @@ function main() {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
util.createFile('./helpers/countries.md', countriesTable)
|
util.createFile('./helpers/countries.md', countriesTable)
|
||||||
|
|
||||||
|
markdownInclude.compileFiles(path.resolve(__dirname, './markdown.json'))
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
console.log(`Countries: ${stats.countries}. Channels: ${stats.channels}.`)
|
console.log(`Done.`)
|
||||||
|
|
Loading…
Reference in New Issue