mirror of
https://github.com/iptv-org/epg
synced 2025-12-17 19:06:58 -05:00
Update update.js
This commit is contained in:
@@ -133,8 +133,39 @@ function convertLangCode(code, from, to) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getChannelPrograms(programs) {
|
function getChannelPrograms(programs) {
|
||||||
let groups = _.groupBy(programs, 'site')
|
let sites = _.groupBy(programs, 'site')
|
||||||
groups = Object.values(groups)
|
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user