mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-13 18:40:06 -04:00
Update store.js
This commit is contained in:
parent
94e17a52c3
commit
fd4764590c
1 changed files with 64 additions and 65 deletions
129
src/store.js
129
src/store.js
|
@ -84,72 +84,71 @@ export function setPageTitle(value) {
|
||||||
async function loadAPI() {
|
async function loadAPI() {
|
||||||
const api = {}
|
const api = {}
|
||||||
|
|
||||||
api.countries = await fetch('https://iptv-org.github.io/api/countries.json')
|
const [
|
||||||
.then(r => r.json())
|
countries,
|
||||||
.then(data => (data.length ? data : []))
|
regions,
|
||||||
.then(data =>
|
subdivisions,
|
||||||
data.map(i => {
|
languages,
|
||||||
i.expanded = false
|
categories,
|
||||||
return i
|
streams,
|
||||||
})
|
blocklist,
|
||||||
)
|
channels,
|
||||||
.then(data => _.keyBy(data, 'code'))
|
guides
|
||||||
.catch(console.error)
|
] = await Promise.all([
|
||||||
|
fetch('https://iptv-org.github.io/api/countries.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data =>
|
||||||
|
data.map(i => {
|
||||||
|
i.expanded = false
|
||||||
|
return i
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(data => _.keyBy(data, 'code')),
|
||||||
|
fetch('https://iptv-org.github.io/api/regions.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => _.keyBy(data, 'code')),
|
||||||
|
fetch('https://iptv-org.github.io/api/subdivisions.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => _.keyBy(data, 'code')),
|
||||||
|
fetch('https://iptv-org.github.io/api/languages.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => _.keyBy(data, 'code')),
|
||||||
|
fetch('https://iptv-org.github.io/api/categories.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => _.keyBy(data, 'id')),
|
||||||
|
fetch('https://iptv-org.github.io/api/streams.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => _.groupBy(data, 'channel')),
|
||||||
|
fetch('https://iptv-org.github.io/api/blocklist.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => _.groupBy(data, 'channel')),
|
||||||
|
fetch('https://iptv-org.github.io/api/channels.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : [])),
|
||||||
|
fetch('https://iptv-org.github.io/api/guides.json')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => (data.length ? data : []))
|
||||||
|
.then(data => data.filter(guide => guide.channel))
|
||||||
|
.then(data => _.sortBy(data, 'lang'))
|
||||||
|
.then(data => _.groupBy(data, 'channel'))
|
||||||
|
])
|
||||||
|
|
||||||
api.regions = await fetch('https://iptv-org.github.io/api/regions.json')
|
api.countries = countries
|
||||||
.then(r => r.json())
|
api.regions = regions
|
||||||
.then(data => (data.length ? data : []))
|
api.subdivisions = subdivisions
|
||||||
.then(data => _.keyBy(data, 'code'))
|
api.languages = languages
|
||||||
.catch(console.error)
|
api.categories = categories
|
||||||
|
api.streams = streams
|
||||||
api.subdivisions = await fetch('https://iptv-org.github.io/api/subdivisions.json')
|
api.blocklist = blocklist
|
||||||
.then(r => r.json())
|
api.channels = channels
|
||||||
.then(data => (data.length ? data : []))
|
api.guides = guides
|
||||||
.then(data => _.keyBy(data, 'code'))
|
|
||||||
.catch(console.error)
|
|
||||||
|
|
||||||
api.languages = await fetch('https://iptv-org.github.io/api/languages.json')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(data => (data.length ? data : []))
|
|
||||||
.then(data => _.keyBy(data, 'code'))
|
|
||||||
.catch(console.error)
|
|
||||||
|
|
||||||
api.categories = await fetch('https://iptv-org.github.io/api/categories.json')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(data => (data.length ? data : []))
|
|
||||||
.then(data => _.keyBy(data, 'id'))
|
|
||||||
.catch(console.error)
|
|
||||||
|
|
||||||
api.streams = await fetch('https://iptv-org.github.io/api/streams.json')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(data => (data.length ? data : []))
|
|
||||||
.then(data => _.groupBy(data, 'channel'))
|
|
||||||
.catch(console.error)
|
|
||||||
|
|
||||||
api.blocklist = await fetch('https://iptv-org.github.io/api/blocklist.json')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(data => (data.length ? data : []))
|
|
||||||
.then(data => _.groupBy(data, 'channel'))
|
|
||||||
.catch(console.error)
|
|
||||||
|
|
||||||
api.channels = await fetch('https://iptv-org.github.io/api/channels.json')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(data => (data.length ? data : []))
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err)
|
|
||||||
return []
|
|
||||||
})
|
|
||||||
|
|
||||||
api.guides = await fetch('https://iptv-org.github.io/api/guides.json')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(data => (data.length ? data : []))
|
|
||||||
.then(data => data.filter(guide => guide.channel))
|
|
||||||
.then(data => _.sortBy(data, 'lang'))
|
|
||||||
.then(data => _.groupBy(data, 'channel'))
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err)
|
|
||||||
return []
|
|
||||||
})
|
|
||||||
|
|
||||||
api.nameIndex = _.groupBy(api.channels, channel => channel.name.toLowerCase())
|
api.nameIndex = _.groupBy(api.channels, channel => channel.name.toLowerCase())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue