24 lines
755 B
JavaScript
Raw Normal View History

2022-02-11 21:07:16 +03:00
const { create: createPlaylist } = require('../../core/playlist')
const { db, logger, file } = require('../../core')
2022-02-08 01:13:35 +03:00
const { orderBy } = require('natural-orderby')
2022-02-11 21:07:16 +03:00
const _ = require('lodash')
2021-12-12 07:10:03 +03:00
async function main() {
2022-02-07 07:00:48 +03:00
await db.streams.load()
2022-02-12 04:05:31 +03:00
let streams = await db.streams.find({})
2022-02-24 22:18:10 +03:00
const levels = { online: 1, blocked: 2, timeout: 3, error: 4, default: 5 }
streams = orderBy(
streams,
2022-06-09 14:00:00 +03:00
['channel', s => levels[s.status] || levels['default'], 'height', 'frame_rate', 'url'],
['asc', 'asc', 'desc', 'desc', 'asc']
2022-02-24 22:18:10 +03:00
)
2021-12-12 07:10:03 +03:00
2022-02-12 04:05:31 +03:00
const files = _.groupBy(streams, 'filepath')
2021-12-12 07:10:03 +03:00
for (const filepath in files) {
2022-02-12 04:05:31 +03:00
const playlist = createPlaylist(files[filepath], { public: false })
2022-02-07 07:00:48 +03:00
await file.create(filepath, playlist.toString())
2021-12-12 07:10:03 +03:00
}
}
main()