mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update update.js
This commit is contained in:
parent
303987fec4
commit
d519b521eb
1 changed files with 16 additions and 14 deletions
|
@ -5,7 +5,7 @@ const _ = require('lodash')
|
||||||
const CHANNELS_PATH = process.env.CHANNELS_PATH || 'sites/**/*.channels.xml'
|
const CHANNELS_PATH = process.env.CHANNELS_PATH || 'sites/**/*.channels.xml'
|
||||||
|
|
||||||
const options = program
|
const options = program
|
||||||
.option('-c, --config <config>', 'Set path to config file', '.readme/config.json')
|
.option('-c, --config <config>', 'Set path to config file', '.readme/readme.json')
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
.opts()
|
.opts()
|
||||||
|
|
||||||
|
@ -46,28 +46,30 @@ main()
|
||||||
async function generateCountriesTable(items = []) {
|
async function generateCountriesTable(items = []) {
|
||||||
logger.info('generating countries table...')
|
logger.info('generating countries table...')
|
||||||
|
|
||||||
let rows = []
|
let data = []
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const country = api.countries.find({ code: item.code.toUpperCase() })
|
const country = api.countries.find({ code: item.code.toUpperCase() })
|
||||||
if (!country) continue
|
if (!country) continue
|
||||||
|
|
||||||
rows.push({
|
data.push([
|
||||||
flag: country.flag,
|
country.name,
|
||||||
name: country.name,
|
`${country.flag} ${country.name}`,
|
||||||
channels: item.count,
|
item.count,
|
||||||
epg: `<code>https://iptv-org.github.io/epg/guides/${item.group}.epg.xml</code>`,
|
`<code>https://iptv-org.github.io/epg/guides/${item.group}.epg.xml</code>`
|
||||||
status: `<a href="https://github.com/iptv-org/epg/actions/workflows/${item.site}.yml"><img src="https://github.com/iptv-org/epg/actions/workflows/${item.site}.yml/badge.svg" alt="${item.site}" style="max-width: 100%;"></a>`
|
])
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rows = _.orderBy(rows, ['name', 'channels'], ['asc', 'desc'])
|
data = _.orderBy(data, [item => item[0], item => item[2]], ['asc', 'desc'])
|
||||||
rows = _.groupBy(rows, 'name')
|
data = data.map(i => {
|
||||||
|
i.shift()
|
||||||
|
return i
|
||||||
|
})
|
||||||
|
data = Object.values(_.groupBy(data, item => item[0]))
|
||||||
|
|
||||||
const output = table.create(rows, [
|
const output = table.create(data, [
|
||||||
'Country ',
|
'Country ',
|
||||||
'Channels',
|
'Channels',
|
||||||
'EPG',
|
'EPG'
|
||||||
'Status '
|
|
||||||
])
|
])
|
||||||
|
|
||||||
await file.create('./.readme/_countries.md', output)
|
await file.create('./.readme/_countries.md', output)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue