mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-14 02:50:07 -04:00
wip
This commit is contained in:
parent
09f6d12085
commit
69185509a0
5 changed files with 119 additions and 68 deletions
66
src/pages/channels/[country]/[name]/+page.server.js
Normal file
66
src/pages/channels/[country]/[name]/+page.server.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
import { transformChannel } from '~/store'
|
||||
import _ from 'lodash'
|
||||
import channels from '~/data/channels.json'
|
||||
import countries from '~/data/countries.json'
|
||||
import regions from '~/data/regions.json'
|
||||
import subdivisions from '~/data/subdivisions.json'
|
||||
import categories from '~/data/categories.json'
|
||||
import blocklist from '~/data/blocklist.json'
|
||||
import languages from '~/data/languages.json'
|
||||
import streams from '~/data/streams.json'
|
||||
|
||||
export async function entries() {
|
||||
return channels.map(channel => {
|
||||
const [name, country] = channel.id.split('.')
|
||||
|
||||
return {
|
||||
country,
|
||||
name
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function load({ params }) {
|
||||
const data = await loadData()
|
||||
|
||||
const country = params.country
|
||||
const name = params.name
|
||||
const id = `${name}.${country}`.toLowerCase()
|
||||
|
||||
const _channels = data.channels
|
||||
|
||||
let streams = []
|
||||
let channel = _channels.find(channel => channel.id.toLowerCase() === id)
|
||||
if (channel) {
|
||||
channel = transformChannel(channel, data)
|
||||
streams = channel._streams
|
||||
}
|
||||
|
||||
return {
|
||||
channel,
|
||||
streams
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
const data = {}
|
||||
|
||||
data.countries = _.keyBy(
|
||||
countries.map(country => {
|
||||
country.expanded = false
|
||||
|
||||
return country
|
||||
}),
|
||||
'code'
|
||||
)
|
||||
|
||||
data.regions = _.keyBy(regions, 'code')
|
||||
data.subdivisions = _.keyBy(subdivisions, 'code')
|
||||
data.languages = _.keyBy(languages, 'code')
|
||||
data.categories = _.keyBy(categories, 'id')
|
||||
data.streams = _.keyBy(streams, 'channel')
|
||||
data.blocklist = _.keyBy(blocklist, 'channel')
|
||||
data.channels = channels
|
||||
|
||||
return data
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
import { get } from 'svelte/store'
|
||||
import { fetchChannels, channels } from '~/store'
|
||||
import apiChannels from '~/data/channels.json'
|
||||
|
||||
export async function entries() {
|
||||
return apiChannels
|
||||
}
|
||||
|
||||
export async function load({ params }) {
|
||||
const id = params.id
|
||||
|
||||
await fetchChannels()
|
||||
|
||||
const channel = get(channels).find(c => c.id === id)
|
||||
let streams = []
|
||||
if (channel) {
|
||||
streams = channel._streams
|
||||
}
|
||||
|
||||
return {
|
||||
channel,
|
||||
streams
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue