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
0890d1dabf
commit
2233601d64
1 changed files with 17 additions and 68 deletions
|
@ -14,18 +14,15 @@ async function main() {
|
|||
const logPath = `${LOGS_DIR}/guides/update.log`
|
||||
let log = await parser.parseLogs(logPath)
|
||||
|
||||
await createCountriesTable(log)
|
||||
await createSourcesTable(log)
|
||||
await createTable(log)
|
||||
|
||||
await updateReadme()
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
async function createSourcesTable(log) {
|
||||
let files = log
|
||||
.filter(c => c.groupedBy === 'site+lang')
|
||||
.reduce((acc, curr) => {
|
||||
async function createTable(log) {
|
||||
let files = _.uniqBy(log, i => i.site + i.channel).reduce((acc, curr) => {
|
||||
if (!acc[curr.filename]) {
|
||||
acc[curr.filename] = {
|
||||
site: curr.site,
|
||||
|
@ -48,7 +45,8 @@ async function createSourcesTable(log) {
|
|||
item.site,
|
||||
item.lang,
|
||||
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>`
|
||||
])
|
||||
}
|
||||
|
||||
|
@ -63,58 +61,9 @@ async function createSourcesTable(log) {
|
|||
})
|
||||
data = Object.values(_.groupBy(data, item => item[0]))
|
||||
|
||||
const output = table.create(data, ['Site', 'Channels', 'EPG'])
|
||||
const output = table.create(data, ['Site', 'Channels', 'EPG', 'Status'])
|
||||
|
||||
await file.create('./.readme/_sources.md', output)
|
||||
}
|
||||
|
||||
async function createCountriesTable(log) {
|
||||
let files = log
|
||||
.filter(c => c.groupedBy === 'country')
|
||||
.reduce((acc, curr) => {
|
||||
if (!acc[curr.filename]) {
|
||||
acc[curr.filename] = {
|
||||
country: curr.country,
|
||||
lang: curr.lang,
|
||||
channels: 0,
|
||||
filename: curr.filename
|
||||
}
|
||||
}
|
||||
|
||||
acc[curr.filename].channels++
|
||||
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
let data = []
|
||||
for (const filename in files) {
|
||||
const item = files[filename]
|
||||
const country = api.countries.find({ code: item.country })
|
||||
if (!country) continue
|
||||
|
||||
data.push([
|
||||
country.name,
|
||||
item.lang,
|
||||
`${country.flag} ${country.name}`,
|
||||
item.channels,
|
||||
`<code>https://iptv-org.github.io/epg/guides/${filename}.xml</code>`
|
||||
])
|
||||
}
|
||||
|
||||
data = _.orderBy(
|
||||
data,
|
||||
[item => item[0], item => (item[1] === 'en' ? Infinity : item[3])],
|
||||
['asc', 'desc']
|
||||
)
|
||||
data = data.map(i => {
|
||||
i.splice(0, 2)
|
||||
return i
|
||||
})
|
||||
data = Object.values(_.groupBy(data, item => item[0]))
|
||||
|
||||
const output = table.create(data, ['Country', 'Channels', 'EPG'])
|
||||
|
||||
await file.create('./.readme/_countries.md', output)
|
||||
await file.create('./.readme/_sites.md', output)
|
||||
}
|
||||
|
||||
async function updateReadme() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue