mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
817 B
TypeScript
26 lines
817 B
TypeScript
import { API_DIR, STREAMS_DIR } from '../../constants'
|
|
import { Logger, PlaylistParser, Storage } from '../../core'
|
|
import { Stream } from '../../models'
|
|
|
|
async function main() {
|
|
const logger = new Logger()
|
|
|
|
logger.info('loading streams...')
|
|
const streamsStorage = new Storage(STREAMS_DIR)
|
|
const parser = new PlaylistParser({ storage: streamsStorage })
|
|
const files = await streamsStorage.list('**/*.m3u')
|
|
let streams = await parser.parse(files)
|
|
streams = streams
|
|
.map(data => new Stream(data))
|
|
.orderBy((stream: Stream) => stream.channel)
|
|
.map((stream: Stream) => stream.toJSON())
|
|
|
|
logger.info(`found ${streams.count()} streams`)
|
|
|
|
logger.info('saving to .api/streams.json...')
|
|
const apiStorage = new Storage(API_DIR)
|
|
await apiStorage.save('streams.json', streams.toJSON())
|
|
}
|
|
|
|
main()
|