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
e8125004c5
commit
79612eb846
1 changed files with 29 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
|||
const { file, markdown, parser, logger, api, table } = require('../../core')
|
||||
const { program } = require('commander')
|
||||
const langs = require('langs')
|
||||
const _ = require('lodash')
|
||||
|
||||
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||
|
@ -22,7 +23,7 @@ async function main() {
|
|||
main()
|
||||
|
||||
async function createTable(log) {
|
||||
let files = _.uniqBy(log, i => i.site + i.channel).reduce((acc, curr) => {
|
||||
let files = log.reduce((acc, curr) => {
|
||||
if (!acc[curr.filename]) {
|
||||
acc[curr.filename] = {
|
||||
site: curr.site,
|
||||
|
@ -37,38 +38,43 @@ async function createTable(log) {
|
|||
return acc
|
||||
}, {})
|
||||
|
||||
let data = []
|
||||
let groups = {}
|
||||
for (const filename in files) {
|
||||
const item = files[filename]
|
||||
const lang = langs.where('1', item.lang)
|
||||
|
||||
data.push([
|
||||
item.site,
|
||||
item.lang,
|
||||
if (!lang) continue
|
||||
|
||||
if (!groups[lang.name]) groups[lang.name] = { lang: lang.name, data: [] }
|
||||
|
||||
groups[lang.name].data.push([
|
||||
`<a href="https://${item.site}">${item.site}</a>`,
|
||||
item.channels,
|
||||
`<code>https://iptv-org.github.io/epg/guides/${filename}.xml</code>`,
|
||||
`<a href="https://github.com/iptv-org/epg/actions/workflows/${filename}.yml"><img src="https://github.com/iptv-org/epg/actions/workflows/${filename}.yml/badge.svg" alt="${filename}" style="max-width: 100%;"></a>`
|
||||
`<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>`
|
||||
])
|
||||
}
|
||||
|
||||
data = _.orderBy(
|
||||
data,
|
||||
[item => item[0], item => (item[1] === 'en' ? Infinity : item[2])],
|
||||
['asc', 'desc']
|
||||
)
|
||||
data = data.map(i => {
|
||||
i.splice(1, 1)
|
||||
return i
|
||||
})
|
||||
data = Object.values(_.groupBy(data, item => item[0]))
|
||||
groups = _.sortBy(Object.values(groups), 'lang')
|
||||
|
||||
const output = table.create(data, [
|
||||
'Site',
|
||||
'Channels',
|
||||
'EPG',
|
||||
'Status '
|
||||
])
|
||||
let guides = ''
|
||||
for (let group of groups) {
|
||||
let lang = group.lang
|
||||
let data = group.data
|
||||
|
||||
await file.create('./.readme/_sites.md', output)
|
||||
data = _.orderBy(data, [item => item[0], item => item[1]], ['asc', 'desc'])
|
||||
data = Object.values(_.groupBy(data, item => item[0]))
|
||||
|
||||
guides += `### ${lang}\r\n\r\n`
|
||||
guides += table.create(data, [
|
||||
'Site',
|
||||
'Channels',
|
||||
'EPG',
|
||||
'Status '
|
||||
])
|
||||
guides += `\r\n\r\n`
|
||||
}
|
||||
await file.create('./.readme/_guides.md', guides)
|
||||
}
|
||||
|
||||
async function updateReadme() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue