Update update-playlists.js

This commit is contained in:
Aleksandr Statciuk 2022-02-08 01:13:35 +03:00
parent 62ce78bbdf
commit 19629fe586

View file

@ -1,4 +1,5 @@
const _ = require('lodash')
const { orderBy } = require('natural-orderby')
const { create: createPlaylist } = require('../core/playlist')
const { db, logger, file } = require('../core')
@ -11,17 +12,10 @@ async function main() {
for (const filepath in files) {
let items = files[filepath]
items = items.sort(naturalOrder)
items = orderBy(items, ['channel_name'], ['asc'])
const playlist = createPlaylist(items, { public: false })
await file.create(filepath, playlist.toString())
}
}
main()
function naturalOrder(a, b) {
return a.channel_name.localeCompare(b.channel_name, undefined, {
numeric: true,
sensitivity: 'base'
})
}