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
b5f6640446
commit
4f7c7d0136
1 changed files with 75 additions and 19 deletions
|
@ -12,20 +12,79 @@ const options = program
|
||||||
async function main() {
|
async function main() {
|
||||||
await api.countries.load().catch(console.error)
|
await api.countries.load().catch(console.error)
|
||||||
const logPath = `${LOGS_DIR}/guides/update.log`
|
const logPath = `${LOGS_DIR}/guides/update.log`
|
||||||
let results = await parser.parseLogs(logPath)
|
let log = await parser.parseLogs(logPath)
|
||||||
let files = results.reduce((acc, curr) => {
|
|
||||||
if (acc[curr.filename]) {
|
|
||||||
acc[curr.filename].channels++
|
|
||||||
} else {
|
|
||||||
acc[curr.filename] = {
|
|
||||||
country: curr.country,
|
|
||||||
channels: 1,
|
|
||||||
filename: curr.filename
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return acc
|
await createCountriesTable(log)
|
||||||
}, {})
|
await createSourcesTable(log)
|
||||||
|
|
||||||
|
await updateReadme()
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function createSourcesTable(log) {
|
||||||
|
let files = log
|
||||||
|
.filter(c => c.groupedBy === 'site+lang')
|
||||||
|
.reduce((acc, curr) => {
|
||||||
|
if (!acc[curr.filename]) {
|
||||||
|
acc[curr.filename] = {
|
||||||
|
site: curr.site,
|
||||||
|
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]
|
||||||
|
|
||||||
|
data.push([
|
||||||
|
item.site,
|
||||||
|
item.lang,
|
||||||
|
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[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, ['Site', 'Channels', 'EPG'])
|
||||||
|
|
||||||
|
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 = []
|
let data = []
|
||||||
for (const filename in files) {
|
for (const filename in files) {
|
||||||
|
@ -35,6 +94,7 @@ async function main() {
|
||||||
|
|
||||||
data.push([
|
data.push([
|
||||||
country.name,
|
country.name,
|
||||||
|
item.lang,
|
||||||
`${country.flag} ${country.name}`,
|
`${country.flag} ${country.name}`,
|
||||||
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>`
|
||||||
|
@ -43,11 +103,11 @@ async function main() {
|
||||||
|
|
||||||
data = _.orderBy(
|
data = _.orderBy(
|
||||||
data,
|
data,
|
||||||
[item => item[0], item => (item[3].includes('_en') ? Infinity : item[2])],
|
[item => item[0], item => (item[1] === 'en' ? Infinity : item[3])],
|
||||||
['asc', 'desc']
|
['asc', 'desc']
|
||||||
)
|
)
|
||||||
data = data.map(i => {
|
data = data.map(i => {
|
||||||
i.shift()
|
i.splice(0, 2)
|
||||||
return i
|
return i
|
||||||
})
|
})
|
||||||
data = Object.values(_.groupBy(data, item => item[0]))
|
data = Object.values(_.groupBy(data, item => item[0]))
|
||||||
|
@ -55,12 +115,8 @@ async function main() {
|
||||||
const output = table.create(data, ['Country', 'Channels', 'EPG'])
|
const output = table.create(data, ['Country', 'Channels', 'EPG'])
|
||||||
|
|
||||||
await file.create('./.readme/_countries.md', output)
|
await file.create('./.readme/_countries.md', output)
|
||||||
|
|
||||||
await updateReadme()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
async function updateReadme() {
|
async function updateReadme() {
|
||||||
logger.info('updating readme.md...')
|
logger.info('updating readme.md...')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue