mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Update validate.ts
This commit is contained in:
parent
b8e6d12d6a
commit
5167a43fb7
1 changed files with 4 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { Storage, Collection, Dictionary, File, Logger } from '@freearhey/core'
|
import { Storage, Collection, Dictionary, File } from '@freearhey/core'
|
||||||
import { ChannelsParser, ApiChannel } from '../../core'
|
import { ChannelsParser, ApiChannel } from '../../core'
|
||||||
import { program } from 'commander'
|
import { program } from 'commander'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
|
@ -6,15 +6,7 @@ import langs from 'langs'
|
||||||
import { DATA_DIR } from '../../constants'
|
import { DATA_DIR } from '../../constants'
|
||||||
import { Channel } from 'epg-grabber'
|
import { Channel } from 'epg-grabber'
|
||||||
|
|
||||||
program
|
program.argument('[filepath]', 'Path to *.channels.xml files to validate').parse(process.argv)
|
||||||
.option(
|
|
||||||
'-c, --channels <path>',
|
|
||||||
'Path to channels.xml file to validate',
|
|
||||||
'sites/**/*.channels.xml'
|
|
||||||
)
|
|
||||||
.parse(process.argv)
|
|
||||||
|
|
||||||
const options = program.opts()
|
|
||||||
|
|
||||||
type ValidationError = {
|
type ValidationError = {
|
||||||
type: 'duplicate' | 'wrong_xmltv_id' | 'wrong_lang'
|
type: 'duplicate' | 'wrong_xmltv_id' | 'wrong_lang'
|
||||||
|
@ -26,11 +18,6 @@ type ValidationError = {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const logger = new Logger()
|
|
||||||
|
|
||||||
logger.info('options:')
|
|
||||||
logger.tree(options)
|
|
||||||
|
|
||||||
const parser = new ChannelsParser({ storage: new Storage() })
|
const parser = new ChannelsParser({ storage: new Storage() })
|
||||||
|
|
||||||
const dataStorage = new Storage(DATA_DIR)
|
const dataStorage = new Storage(DATA_DIR)
|
||||||
|
@ -39,8 +26,9 @@ async function main() {
|
||||||
|
|
||||||
let totalFiles = 0
|
let totalFiles = 0
|
||||||
let totalErrors = 0
|
let totalErrors = 0
|
||||||
|
|
||||||
const storage = new Storage()
|
const storage = new Storage()
|
||||||
const files: string[] = await storage.list(options.channels)
|
const files = program.args.length ? program.args : await storage.list('sites/**/*.channels.xml')
|
||||||
for (const filepath of files) {
|
for (const filepath of files) {
|
||||||
const file = new File(filepath)
|
const file = new File(filepath)
|
||||||
if (file.extension() !== 'xml') continue
|
if (file.extension() !== 'xml') continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue