mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 01:20:08 -04:00
Update app.js
This commit is contained in:
parent
2563aab667
commit
6ed6e6c887
3 changed files with 1147 additions and 13 deletions
|
@ -10,10 +10,39 @@ document.addEventListener('alpine:init', () => {
|
|||
},
|
||||
|
||||
async init() {
|
||||
this.items = await fetch('items.json')
|
||||
const countries = await fetch('api/countries.json')
|
||||
.then(response => response.json())
|
||||
.catch(console.log)
|
||||
|
||||
const channels = await fetch('api/channels.json')
|
||||
.then(response => response.json())
|
||||
.catch(console.log)
|
||||
|
||||
let items = {}
|
||||
for (let channel of channels) {
|
||||
if (!items[channel.country]) {
|
||||
const country = countries[channel.country]
|
||||
|
||||
items[channel.country] = {
|
||||
flag: country.flag,
|
||||
name: country.name,
|
||||
expanded: false,
|
||||
channels: []
|
||||
}
|
||||
}
|
||||
|
||||
channel.hash = `${channel.id}_${channel.name}`.toLowerCase()
|
||||
|
||||
items[channel.country].channels.push(channel)
|
||||
}
|
||||
|
||||
items = Object.values(items).sort((a, b) => {
|
||||
if (a.name > b.name) return 1
|
||||
if (a.name < b.name) return -1
|
||||
return 0
|
||||
})
|
||||
|
||||
this.items = items
|
||||
this.isLoading = false
|
||||
}
|
||||
}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue