mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update parse-channels.js
This commit is contained in:
parent
8c2b8f464b
commit
189a370f3d
1 changed files with 16 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
||||||
const { Command } = require('commander')
|
const { Command } = require('commander')
|
||||||
const fs = require('fs')
|
const { db } = require('../core')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const _ = require('lodash')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
const program = new Command()
|
const program = new Command()
|
||||||
program
|
program
|
||||||
|
@ -12,6 +14,7 @@ program
|
||||||
const options = program.opts()
|
const options = program.opts()
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
await db.channels.load()
|
||||||
const config = require(path.resolve(options.config))
|
const config = require(path.resolve(options.config))
|
||||||
const args = {}
|
const args = {}
|
||||||
options.set.forEach(arg => {
|
options.set.forEach(arg => {
|
||||||
|
@ -22,12 +25,19 @@ async function main() {
|
||||||
if (isPromise(channels)) {
|
if (isPromise(channels)) {
|
||||||
channels = await channels
|
channels = await channels
|
||||||
}
|
}
|
||||||
channels = channels.map(channel => {
|
channels = _.uniqBy(channels, 'site_id')
|
||||||
if (!channel.xmltv_id) {
|
|
||||||
channel.xmltv_id = channel.name
|
for (const channel of channels) {
|
||||||
|
const data = await db.channels
|
||||||
|
.find({ site: config.site, site_id: channel.site_id.toString() })
|
||||||
|
.limit(1)
|
||||||
|
if (data.length) {
|
||||||
|
const first = data[0]
|
||||||
|
channel.xmltv_id = first.xmltv_id
|
||||||
|
channel.name = first.name
|
||||||
}
|
}
|
||||||
return channel
|
}
|
||||||
})
|
|
||||||
const xml = json2xml(channels, config.site)
|
const xml = json2xml(channels, config.site)
|
||||||
|
|
||||||
const dir = path.parse(options.config).dir
|
const dir = path.parse(options.config).dir
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue