Update format.js
This commit is contained in:
parent
bb62e295a4
commit
2eddce0e83
@ -1,6 +1,6 @@
|
||||
const parser = require('./parser')
|
||||
const utils = require('./utils')
|
||||
const log = require('./log')
|
||||
const parser = require('./helpers/parser')
|
||||
const utils = require('./helpers/utils')
|
||||
const log = require('./helpers/log')
|
||||
|
||||
async function main() {
|
||||
log.start()
|
||||
@ -9,9 +9,13 @@ async function main() {
|
||||
let playlists = parser.parseIndex().filter(i => i.url !== 'channels/unsorted.m3u')
|
||||
for (const playlist of playlists) {
|
||||
log.print(`\nProcessing '${playlist.url}'...`)
|
||||
await parser.parsePlaylist(playlist.url).then(sortChannels).then(utils.savePlaylist)
|
||||
await parser
|
||||
.parsePlaylist(playlist.url)
|
||||
.then(sortChannels)
|
||||
.then(p => p.save())
|
||||
}
|
||||
|
||||
log.print('\n')
|
||||
log.finish()
|
||||
}
|
||||
|
||||
@ -19,9 +23,10 @@ async function sortChannels(playlist) {
|
||||
const channels = [...playlist.channels]
|
||||
utils.sortBy(channels, ['name', 'url'])
|
||||
|
||||
if (JSON.stringify(playlist.channels) !== JSON.stringify(channels)) log.print('updated')
|
||||
|
||||
playlist.channels = channels
|
||||
if (JSON.stringify(playlist.channels) !== JSON.stringify(channels)) {
|
||||
log.print('updated')
|
||||
playlist.channels = channels
|
||||
}
|
||||
|
||||
return playlist
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user