mirror of
https://github.com/iptv-org/epg
synced 2026-05-12 20:35:03 -04:00
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import { WorkerGuideSource } from './worker'
|
|
|
|
export interface ApiGuideData {
|
|
channel: string | null
|
|
feed: string | null
|
|
site: string
|
|
site_id: string
|
|
site_name: string
|
|
lang: string | null
|
|
sources?: WorkerGuideSource[]
|
|
}
|
|
|
|
export class ApiGuide {
|
|
channel: string | null
|
|
feed: string | null
|
|
site: string
|
|
site_id: string
|
|
site_name: string
|
|
lang: string
|
|
sources: WorkerGuideSource[] = []
|
|
|
|
constructor(data: ApiGuideData) {
|
|
this.channel = data.channel || null
|
|
this.feed = data.feed || null
|
|
this.site = data.site
|
|
this.site_id = data.site_id
|
|
this.site_name = data.site_name
|
|
this.lang = data.lang || 'en'
|
|
this.sources = data.sources || []
|
|
}
|
|
|
|
addSource(source: ApiGuideSource): this {
|
|
this.sources.push(source)
|
|
|
|
return this
|
|
}
|
|
|
|
toJSON(): ApiGuideData {
|
|
return {
|
|
channel: this.channel,
|
|
feed: this.feed,
|
|
site: this.site,
|
|
site_id: this.site_id,
|
|
site_name: this.site_name,
|
|
lang: this.lang,
|
|
sources: this.sources
|
|
}
|
|
}
|
|
}
|