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
dc36f53a75
commit
e56df2c966
1 changed files with 10 additions and 23 deletions
|
@ -2,35 +2,22 @@ const { file, parser, logger } = require('../../core')
|
||||||
const { program } = require('commander')
|
const { program } = require('commander')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
|
||||||
const CHANNELS_PATH = process.env.CHANNELS_PATH || 'sites/**/*.channels.xml'
|
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
|
||||||
const OUTPUT_DIR = process.env.OUTPUT_DIR || '.api'
|
const OUTPUT_DIR = process.env.OUTPUT_DIR || '.api'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
let guides = []
|
let guides = []
|
||||||
|
|
||||||
const files = await file.list(CHANNELS_PATH).catch(console.error)
|
const logPath = `${LOGS_DIR}/guides/update.log`
|
||||||
for (const filepath of files) {
|
const results = await parser.parseLogs(logPath)
|
||||||
try {
|
|
||||||
const { site, channels } = await parser.parseChannels(filepath)
|
|
||||||
const dir = file.dirname(filepath)
|
|
||||||
const config = require(file.resolve(`${dir}/${site}.config.js`))
|
|
||||||
if (config.ignore) continue
|
|
||||||
|
|
||||||
const filename = file.basename(filepath)
|
for (const result of results) {
|
||||||
const [__, suffix] = filename.match(/\_(.*)\.channels\.xml$/) || [null, null]
|
guides.push({
|
||||||
|
channel: result.channel,
|
||||||
for (const channel of channels) {
|
site: result.site,
|
||||||
guides.push({
|
lang: result.lang,
|
||||||
channel: channel.id,
|
url: `https://iptv-org.github.io/epg/guides/${result.filename}.xml.gz`
|
||||||
site: channel.site,
|
})
|
||||||
lang: channel.lang,
|
|
||||||
url: `https://iptv-org.github.io/epg/guides/${suffix}/${site}.epg.xml.gz`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guides = _.sortBy(guides, 'channel')
|
guides = _.sortBy(guides, 'channel')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue