Update format.js

- added `verbose` mode
- added support multiple icon sources
This commit is contained in:
freearhey 2019-08-17 14:58:28 +03:00
parent c7ba6bd6a4
commit 56973b6f49
1 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,7 @@
const util = require('./util') const util = require('./util')
const debug = false const debug = false
const verbose = false
const parseEpg = process.env.npm_config_epg || false const parseEpg = process.env.npm_config_epg || false
let stats = { let stats = {
@ -28,7 +29,7 @@ async function main() {
continue continue
} }
if(debug) { if(verbose) {
console.log(`Clear cache...`) console.log(`Clear cache...`)
} }
util.clearCache() util.clearCache()
@ -36,7 +37,7 @@ async function main() {
console.log(`Parsing '${country.url}'...`) console.log(`Parsing '${country.url}'...`)
const playlist = util.parsePlaylist(country.url) const playlist = util.parsePlaylist(country.url)
if(debug) { if(verbose) {
console.log(`Creating channels list...`) console.log(`Creating channels list...`)
} }
let channels = [] let channels = []
@ -80,16 +81,17 @@ async function main() {
if(!channel.name && c.names[0]) { if(!channel.name && c.names[0]) {
channel.name = c.names[0] channel.name = c.names[0]
updated = true updated = true
if(debug) { if(verbose) {
console.log(`Added name '${c.names[0]}' to '${channel.id}'`) console.log(`Added name '${c.names[0]}' to '${channel.id}'`)
} }
} }
if(!channel.logo && c.icon) { if(!channel.logo && c.icon) {
channel.logo = c.icon const icon = c.icon.split('|')[0]
channel.logo = icon
updated = true updated = true
if(debug) { if(verbose) {
console.log(`Added logo '${c.icon}' to '${channel.id}'`) console.log(`Added logo '${icon}' to '${channel.id}'`)
} }
} }
@ -99,7 +101,7 @@ async function main() {
} }
} }
if(debug) { if(verbose) {
console.log(`Sorting channels...`) console.log(`Sorting channels...`)
} }
channels = util.sortByTitle(channels) channels = util.sortByTitle(channels)