Files
epg/scripts/commands/api/update.js

31 lines
809 B
JavaScript
Raw Normal View History

2022-02-26 23:21:44 +03:00
const { file, parser, logger } = require('../../core')
2022-02-03 20:41:03 +03:00
const { program } = require('commander')
2022-01-09 16:09:19 +03:00
const _ = require('lodash')
2022-10-26 04:41:30 +03:00
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs'
2022-02-28 22:13:05 +03:00
const OUTPUT_DIR = process.env.OUTPUT_DIR || '.api'
2022-01-09 16:09:19 +03:00
async function main() {
2022-02-03 20:41:03 +03:00
let guides = []
2022-02-27 18:04:17 +03:00
2022-10-26 04:41:30 +03:00
const logPath = `${LOGS_DIR}/guides/update.log`
const results = await parser.parseLogs(logPath)
2022-02-27 18:04:17 +03:00
2022-10-26 04:41:30 +03:00
for (const result of results) {
guides.push({
channel: result.channel,
site: result.site,
lang: result.lang,
2022-11-06 07:20:16 +03:00
url: `https://iptv-org.github.io/epg/guides/${result.filename}.xml`
2022-10-26 04:41:30 +03:00
})
2022-01-21 20:10:45 +03:00
}
2022-01-18 22:19:36 +03:00
2022-02-03 20:41:03 +03:00
guides = _.sortBy(guides, 'channel')
2022-01-18 22:19:36 +03:00
2022-02-03 20:41:03 +03:00
const outputFilepath = `${OUTPUT_DIR}/guides.json`
await file.create(outputFilepath, JSON.stringify(guides))
logger.info(`saved to "${outputFilepath}"...`)
2022-01-31 01:36:14 +03:00
}
2022-02-03 20:41:03 +03:00
main()