mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 02:16:40 -05:00
36 lines
831 B
TypeScript
36 lines
831 B
TypeScript
import type { GuideData } from '../types/guide'
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
|
|
export class Guide {
|
|
channelId?: string
|
|
feedId?: string
|
|
siteDomain?: string
|
|
siteId?: string
|
|
siteName?: string
|
|
languageCode?: string
|
|
|
|
constructor(data?: GuideData) {
|
|
if (!data) return
|
|
|
|
this.channelId = data.channel
|
|
this.feedId = data.feed
|
|
this.siteDomain = data.site
|
|
this.siteId = data.site_id
|
|
this.siteName = data.site_name
|
|
this.languageCode = data.lang
|
|
}
|
|
|
|
getUUID(): string {
|
|
if (!this.getStreamId() || !this.siteId) return uuidv4()
|
|
|
|
return this.getStreamId() + this.siteId
|
|
}
|
|
|
|
getStreamId(): string | undefined {
|
|
if (!this.channelId) return undefined
|
|
if (!this.feedId) return this.channelId
|
|
|
|
return `${this.channelId}@${this.feedId}`
|
|
}
|
|
}
|