mirror of
https://github.com/iptv-org/iptv
synced 2026-04-17 08:19:38 -04:00
Update scripts
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
import { Collection, Logger, Storage } from '@freearhey/core'
|
||||
import { Collection, File, Storage } from '@freearhey/core'
|
||||
import { Stream, Playlist } from '../models'
|
||||
import { Generator } from './generator'
|
||||
import { PUBLIC_DIR } from '../constants'
|
||||
import { Generator } from './generator'
|
||||
import { EOL } from 'node:os'
|
||||
|
||||
type IndexGeneratorProps = {
|
||||
streams: Collection
|
||||
logger: Logger
|
||||
logFile: File
|
||||
}
|
||||
|
||||
export class IndexGenerator implements Generator {
|
||||
streams: Collection
|
||||
storage: Storage
|
||||
logger: Logger
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logger }: IndexGeneratorProps) {
|
||||
constructor({ streams, logFile }: IndexGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logger = logger
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
async generate(): Promise<void> {
|
||||
@@ -27,6 +28,8 @@ export class IndexGenerator implements Generator {
|
||||
const playlist = new Playlist(sfwStreams, { public: true })
|
||||
const filepath = 'index.m3u'
|
||||
await this.storage.save(filepath, playlist.toString())
|
||||
this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }))
|
||||
this.logFile.append(
|
||||
JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user