mirror of
https://github.com/iptv-org/iptv.git
synced 2024-09-06 00:02:24 +02:00
23 lines
654 B
JavaScript
23 lines
654 B
JavaScript
const { create: createPlaylist } = require('../../core/playlist')
|
|
const { db, logger, file } = require('../../core')
|
|
const { orderBy } = require('natural-orderby')
|
|
const _ = require('lodash')
|
|
|
|
async function main() {
|
|
await db.streams.load()
|
|
let streams = await db.streams.find({})
|
|
streams = orderBy(
|
|
streams,
|
|
['channel_name', i => i.status.level, i => i.resolution.height, 'url'],
|
|
['asc', 'asc', 'desc', 'asc']
|
|
)
|
|
|
|
const files = _.groupBy(streams, 'filepath')
|
|
for (const filepath in files) {
|
|
const playlist = createPlaylist(files[filepath], { public: false })
|
|
await file.create(filepath, playlist.toString())
|
|
}
|
|
}
|
|
|
|
main()
|