iptv/scripts/commands/update-playlists.js

20 lines
553 B
JavaScript
Raw Normal View History

2021-12-12 05:10:03 +01:00
const _ = require('lodash')
2022-02-07 05:00:48 +01:00
const { create: createPlaylist } = require('../core/playlist')
const { db, logger, file } = require('../core')
2021-12-12 05:10:03 +01:00
async function main() {
2022-02-07 05:00:48 +01:00
await db.streams.load()
let items = await db.streams
2021-12-12 05:10:03 +01:00
.find({})
.sort({ name: 1, 'status.level': 1, 'resolution.height': -1, url: 1 })
const files = _.groupBy(items, 'filepath')
for (const filepath in files) {
const items = files[filepath]
2022-02-07 05:00:48 +01:00
const playlist = createPlaylist(items, { public: false })
await file.create(filepath, playlist.toString())
2021-12-12 05:10:03 +01:00
}
}
main()