const markdownInclude = require('markdown-include')
const path = require('path')
const fs = require('fs')
const countries = require('./countries.json')
const file = require('./file.js')
async function main() {
console.log('Starting...')
file
.list([], ['us-local'])
.then(files => {
files = files.map(str => str.match(/channels\/(.*).xml/i)[1])
generateTable(files)
generateReadme()
})
.finally(() => {
console.log('Finish')
})
}
function generateTable(files) {
console.log('Generating countries table...')
const output = []
for (const country of countries) {
if (files.includes(country.code)) {
output.push({
country: `${country.flag} ${country.name}`,
guide: `https://iptv-org.github.io/epg/guides/${country.code}.epg.xml
`
})
}
}
const table = generateHtmlTable(output, {
columns: [
{ name: 'Country', align: 'left', nowrap: true },
{ name: 'EPG', align: 'left', nowrap: true }
]
})
fs.writeFileSync(path.resolve('./.readme/_countries.md'), table)
}
function generateHtmlTable(data, options) {
let output = '
${column.name} | ` } output += '
---|
${item[prop]} | ` i++ } output += '