mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -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 { file, markdown, parser, logger, api, table } = require('../../core')
|
||||||
const { program } = require('commander')
|
const { program } = require('commander')
|
||||||
|
const langs = require('langs')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
|
||||||
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||||
|
@ -22,7 +23,7 @@ async function main() {
|
||||||
main()
|
main()
|
||||||
|
|
||||||
async function createTable(log) {
|
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]) {
|
if (!acc[curr.filename]) {
|
||||||
acc[curr.filename] = {
|
acc[curr.filename] = {
|
||||||
site: curr.site,
|
site: curr.site,
|
||||||
|
@ -37,38 +38,43 @@ async function createTable(log) {
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
let data = []
|
let groups = {}
|
||||||
for (const filename in files) {
|
for (const filename in files) {
|
||||||
const item = files[filename]
|
const item = files[filename]
|
||||||
|
const lang = langs.where('1', item.lang)
|
||||||
|
|
||||||
data.push([
|
if (!lang) continue
|
||||||
item.site,
|
|
||||||
item.lang,
|
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,
|
item.channels,
|
||||||
`<code>https://iptv-org.github.io/epg/guides/${filename}.xml</code>`,
|
`<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(
|
groups = _.sortBy(Object.values(groups), 'lang')
|
||||||
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]))
|
|
||||||
|
|
||||||
const output = table.create(data, [
|
let guides = ''
|
||||||
'Site',
|
for (let group of groups) {
|
||||||
'Channels',
|
let lang = group.lang
|
||||||
'EPG',
|
let data = group.data
|
||||||
'Status '
|
|
||||||
])
|
|
||||||
|
|
||||||
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() {
|
async function updateReadme() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue