Files
epg/scripts/models/guide.ts

36 lines
806 B
TypeScript
Raw Normal View History

2025-07-18 22:51:01 +03:00
import { Collection, DateTime } from '@freearhey/core'
import { generateXMLTV } from 'epg-grabber'
2025-04-19 02:06:15 +03:00
2025-07-18 22:51:01 +03:00
type GuideData = {
channels: Collection
programs: Collection
filepath: string
gzip: boolean
}
2025-04-19 02:06:15 +03:00
2025-07-18 22:51:01 +03:00
export class Guide {
channels: Collection
programs: Collection
filepath: string
gzip: boolean
2025-04-19 02:06:15 +03:00
2025-07-18 22:51:01 +03:00
constructor({ channels, programs, filepath, gzip }: GuideData) {
this.channels = channels
this.programs = programs
this.filepath = filepath
this.gzip = gzip || false
2025-04-19 02:06:15 +03:00
}
2025-07-18 22:51:01 +03:00
toString() {
const currDate = new DateTime(process.env.CURR_DATE || new Date().toISOString(), {
timezone: 'UTC'
})
2025-04-19 02:06:15 +03:00
2025-07-18 22:51:01 +03:00
return generateXMLTV({
channels: this.channels.all(),
programs: this.programs.all(),
date: currDate.toJSON()
})
2025-04-19 02:06:15 +03:00
}
}