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
5e4dd0c9f3
commit
5ec027b627
1 changed files with 34 additions and 3 deletions
|
@ -133,8 +133,39 @@ function convertLangCode(code, from, to) {
|
|||
}
|
||||
|
||||
function getChannelPrograms(programs) {
|
||||
let groups = _.groupBy(programs, 'site')
|
||||
groups = Object.values(groups)
|
||||
let sites = _.groupBy(programs, 'site')
|
||||
|
||||
return groups[0]
|
||||
let priority = 0
|
||||
let selected
|
||||
for (let site in sites) {
|
||||
let prog = sites[site][0]
|
||||
|
||||
let sitePriority = calcPriority(prog)
|
||||
|
||||
if (sitePriority > priority) {
|
||||
selected = site
|
||||
priority = sitePriority
|
||||
}
|
||||
}
|
||||
|
||||
return sites[selected] || []
|
||||
}
|
||||
|
||||
function calcPriority(program) {
|
||||
let priority = 0
|
||||
for (let prop in program) {
|
||||
let value = program[prop]
|
||||
|
||||
if (Array.isArray(value) && value.length) {
|
||||
priority++
|
||||
} else if (typeof value === 'string' && value) {
|
||||
priority++
|
||||
} else if (value && typeof value === 'object' && Object.values(value).map(Boolean).length) {
|
||||
priority++
|
||||
}
|
||||
}
|
||||
|
||||
console.log(priority)
|
||||
|
||||
return priority
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue