Format each playlist at every run

This commit is contained in:
freearhey 2020-05-26 15:57:29 +03:00
parent b9f49f1d81
commit 9dd44875ef
1 changed files with 1 additions and 17 deletions

View File

@ -47,19 +47,12 @@ async function main() {
} }
} }
if (playlist.changed) { updatePlaylist(item.url, playlist)
updatePlaylist(item.url, playlist)
updated++
} else {
console.log('Nothing is changed')
}
} }
console.log(`Processing 'channels/unsorted.m3u'...`) console.log(`Processing 'channels/unsorted.m3u'...`)
filterUnsorted() filterUnsorted()
console.log(`Updated ${updated} playlist(s)`)
console.log('Done.\n') console.log('Done.\n')
} }
@ -85,9 +78,6 @@ function parsePlaylist(url) {
function sortChannels(playlist) { function sortChannels(playlist) {
const channels = JSON.stringify(playlist.items) const channels = JSON.stringify(playlist.items)
playlist.items = helper.sortBy(playlist.items, ['name', 'url']) playlist.items = helper.sortBy(playlist.items, ['name', 'url'])
if (channels !== JSON.stringify(playlist.items)) {
playlist.changed = true
}
return playlist return playlist
} }
@ -109,10 +99,6 @@ function removeDuplicates(playlist) {
return result return result
}) })
if (channels !== JSON.stringify(playlist.items)) {
playlist.changed = true
}
return playlist return playlist
} }
@ -168,8 +154,6 @@ function updatePlaylist(filepath, playlist) {
for (let channel of playlist.items) { for (let channel of playlist.items) {
helper.appendToFile(filepath, channel.toShortString()) helper.appendToFile(filepath, channel.toShortString())
} }
console.log(`Playlist '${filepath}' has been updated`)
} }
function filterUnsorted() { function filterUnsorted() {