iptv-database/scripts/models/channel.ts

92 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-10-06 22:14:21 -04:00
type ChannelProps = {
id: string
2023-10-16 07:45:12 -04:00
name?: string
alt_names?: string[]
network?: string
owners?: string[]
country?: string
subdivision?: string
city?: string
broadcast_area?: string[]
languages?: string[]
categories?: string[]
is_nsfw?: boolean
launched?: string
closed?: string
replaced_by?: string
website?: string
logo?: string
2023-10-06 22:14:21 -04:00
}
export class Channel {
id: string
2023-10-16 07:45:12 -04:00
name?: string
alt_names?: string[]
network?: string
owners?: string[]
country?: string
subdivision?: string
city?: string
broadcast_area?: string[]
languages?: string[]
categories?: string[]
is_nsfw?: boolean
launched?: string
closed?: string
replaced_by?: string
website?: string
logo?: string
2023-10-06 22:14:21 -04:00
constructor({
id,
name,
alt_names,
network,
owners,
country,
subdivision,
city,
broadcast_area,
languages,
categories,
is_nsfw,
launched,
closed,
replaced_by,
website,
logo
}: ChannelProps) {
this.id = id
this.name = name
this.alt_names = alt_names
this.network = network
this.owners = owners
this.country = country
this.subdivision = subdivision
this.city = city
this.broadcast_area = broadcast_area
this.languages = languages
this.categories = categories
this.is_nsfw = is_nsfw
this.launched = launched
this.closed = closed
this.replaced_by = replaced_by
this.website = website
this.logo = logo
}
2023-10-12 02:06:46 -04:00
data() {
const { ...object } = this
return object
}
merge(channel: Channel) {
2023-10-16 07:45:12 -04:00
const data: { [key: string]: string | string[] | boolean | undefined } = channel.data()
2023-10-12 02:06:46 -04:00
for (const prop in data) {
if (data[prop] === undefined) continue
this[prop] = data[prop]
2023-10-06 22:14:21 -04:00
}
}
}