Fixes build error

This commit is contained in:
freearhey 2025-03-08 02:54:20 +03:00
parent f2c026cec0
commit 89e188f6b2
3 changed files with 63 additions and 57 deletions

View file

@ -41,4 +41,10 @@ export class Channel {
this._guides = data.guides || [] this._guides = data.guides || []
this._blocklistRecords = data.blocklistRecords || [] this._blocklistRecords = data.blocklistRecords || []
} }
toObject() {
const { ...object } = this
return object
}
} }

View file

@ -1,4 +1,4 @@
import { transformChannel } from '~/store' import { createChannel } from '~/store'
import _ from 'lodash' import _ from 'lodash'
import channels from '~/data/channels.json' import channels from '~/data/channels.json'
import countries from '~/data/countries.json' import countries from '~/data/countries.json'
@ -47,6 +47,6 @@ export function load({ params }) {
let channel = data.channels[id] let channel = data.channels[id]
return { return {
channel: channel ? transformChannel(channel, data) : null channel: channel ? createChannel(channel, data).toObject() : null
} }
} }

View file

@ -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() { async function loadAPI() {
const api = {} const api = {}
@ -159,61 +214,6 @@ async function loadAPI() {
return api 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() { function getStreams() {
let streams = [] let streams = []
get(selected).forEach(channel => { get(selected).forEach(channel => {