mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-11 17:40:05 -04:00
Fixes build error
This commit is contained in:
parent
f2c026cec0
commit
89e188f6b2
3 changed files with 63 additions and 57 deletions
|
@ -41,4 +41,10 @@ export class Channel {
|
|||
this._guides = data.guides || []
|
||||
this._blocklistRecords = data.blocklistRecords || []
|
||||
}
|
||||
|
||||
toObject() {
|
||||
const { ...object } = this
|
||||
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { transformChannel } from '~/store'
|
||||
import { createChannel } from '~/store'
|
||||
import _ from 'lodash'
|
||||
import channels from '~/data/channels.json'
|
||||
import countries from '~/data/countries.json'
|
||||
|
@ -47,6 +47,6 @@ export function load({ params }) {
|
|||
let channel = data.channels[id]
|
||||
|
||||
return {
|
||||
channel: channel ? transformChannel(channel, data) : null
|
||||
channel: channel ? createChannel(channel, data).toObject() : null
|
||||
}
|
||||
}
|
||||
|
|
110
src/store.js
110
src/store.js
|
@ -85,6 +85,61 @@ export function setPageTitle(value) {
|
|||
}
|
||||
}
|
||||
|
||||
export function createChannel(data, api) {
|
||||
let broadcastArea = []
|
||||
let regionCountries = []
|
||||
|
||||
data.broadcast_area.forEach(areaCode => {
|
||||
const [type, code] = areaCode.split('/')
|
||||
switch (type) {
|
||||
case 'c':
|
||||
const country = api.countries[code]
|
||||
if (country) broadcastArea.push({ type, code: country.code, name: country.name })
|
||||
break
|
||||
case 'r':
|
||||
const region = api.regions[code]
|
||||
if (region) {
|
||||
broadcastArea.push({ type, code: region.code, name: region.name })
|
||||
regionCountries = [
|
||||
...regionCountries,
|
||||
...region.countries.map(code => api.countries[code]).filter(Boolean)
|
||||
]
|
||||
}
|
||||
break
|
||||
case 's':
|
||||
const subdivision = api.subdivisions[code]
|
||||
if (subdivision)
|
||||
broadcastArea.push({ type, code: subdivision.code, name: subdivision.name })
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
return new Channel({
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
altNames: data.alt_names,
|
||||
network: data.network,
|
||||
owners: data.owners,
|
||||
city: data.city,
|
||||
country: api.countries[data.country],
|
||||
subdivision: api.subdivisions[data.subdivision],
|
||||
languages: data.languages.map(code => api.languages[code]).filter(Boolean),
|
||||
categories: data.categories.map(id => api.categories[id]).filter(Boolean),
|
||||
isNSFW: data.is_nsfw,
|
||||
launched: data.launched,
|
||||
closed: data.closed,
|
||||
replacedBy: data.replaced_by,
|
||||
website: data.website,
|
||||
logo: data.logo,
|
||||
streams: api.streams[data.id],
|
||||
guides: api.guides[data.id],
|
||||
blocklistRecords: api.blocklist[data.id],
|
||||
hasUniqueName: api.nameIndex[data.name.toLowerCase()].length === 1,
|
||||
broadcastArea,
|
||||
regionCountries
|
||||
})
|
||||
}
|
||||
|
||||
async function loadAPI() {
|
||||
const api = {}
|
||||
|
||||
|
@ -159,61 +214,6 @@ async function loadAPI() {
|
|||
return api
|
||||
}
|
||||
|
||||
function createChannel(data, api) {
|
||||
let broadcastArea = []
|
||||
let regionCountries = []
|
||||
|
||||
data.broadcast_area.forEach(areaCode => {
|
||||
const [type, code] = areaCode.split('/')
|
||||
switch (type) {
|
||||
case 'c':
|
||||
const country = api.countries[code]
|
||||
if (country) broadcastArea.push({ type, code: country.code, name: country.name })
|
||||
break
|
||||
case 'r':
|
||||
const region = api.regions[code]
|
||||
if (region) {
|
||||
broadcastArea.push({ type, code: region.code, name: region.name })
|
||||
regionCountries = [
|
||||
...regionCountries,
|
||||
...region.countries.map(code => api.countries[code]).filter(Boolean)
|
||||
]
|
||||
}
|
||||
break
|
||||
case 's':
|
||||
const subdivision = api.subdivisions[code]
|
||||
if (subdivision)
|
||||
broadcastArea.push({ type, code: subdivision.code, name: subdivision.name })
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
return new Channel({
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
altNames: data.alt_names,
|
||||
network: data.network,
|
||||
owners: data.owners,
|
||||
city: data.city,
|
||||
country: api.countries[data.country],
|
||||
subdivision: api.subdivisions[data.subdivision],
|
||||
languages: data.languages.map(code => api.languages[code]).filter(Boolean),
|
||||
categories: data.categories.map(id => api.categories[id]).filter(Boolean),
|
||||
isNSFW: data.is_nsfw,
|
||||
launched: data.launched,
|
||||
closed: data.closed,
|
||||
replacedBy: data.replaced_by,
|
||||
website: data.website,
|
||||
logo: data.logo,
|
||||
streams: api.streams[data.id],
|
||||
guides: api.guides[data.id],
|
||||
blocklistRecords: api.blocklist[data.id],
|
||||
hasUniqueName: api.nameIndex[data.name.toLowerCase()].length === 1,
|
||||
broadcastArea,
|
||||
regionCountries
|
||||
})
|
||||
}
|
||||
|
||||
function getStreams() {
|
||||
let streams = []
|
||||
get(selected).forEach(channel => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue