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-13 07:23:40 +03:00
|
|
|
streams = orderBy(streams, ['title', 'height', 'url'], ['asc', 'desc', 'asc'])
|
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()
|