Updated Playlist.save() method
This commit is contained in:
parent
27136370aa
commit
1c05547389
@ -90,6 +90,7 @@ async function checkStatus(playlist) {
|
||||
if (playlist.channels.length !== channels.length) {
|
||||
log.print(`File '${playlist.url}' has been updated\n`)
|
||||
playlist.channels = channels
|
||||
playlist.updated = true
|
||||
}
|
||||
|
||||
return playlist
|
||||
|
@ -86,6 +86,7 @@ async function detectResolution(playlist) {
|
||||
if (updated) {
|
||||
log.print(`File '${playlist.url}' has been updated\n`)
|
||||
playlist.channels = channels
|
||||
playlist.updated = true
|
||||
}
|
||||
|
||||
return playlist
|
||||
|
@ -26,6 +26,7 @@ async function sortChannels(playlist) {
|
||||
if (JSON.stringify(playlist.channels) !== JSON.stringify(channels)) {
|
||||
log.print('updated')
|
||||
playlist.channels = channels
|
||||
playlist.updated = true
|
||||
}
|
||||
|
||||
return playlist
|
||||
|
@ -10,6 +10,7 @@ module.exports = class Playlist {
|
||||
this.channels = items
|
||||
.map(item => new Channel({ data: item, header, sourceUrl: url }))
|
||||
.filter(channel => channel.url)
|
||||
this.updated = false
|
||||
}
|
||||
|
||||
toString(options = {}) {
|
||||
@ -31,10 +32,8 @@ module.exports = class Playlist {
|
||||
}
|
||||
|
||||
save() {
|
||||
const original = file.read(this.url)
|
||||
const output = this.toString()
|
||||
if (original !== output) {
|
||||
file.create(this.url, output)
|
||||
if (this.updated) {
|
||||
file.create(this.url, this.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ async function removeDuplicates(playlist) {
|
||||
if (playlist.channels.length !== channels.length) {
|
||||
log.print('updated')
|
||||
playlist.channels = channels
|
||||
playlist.updated = true
|
||||
}
|
||||
|
||||
return playlist
|
||||
@ -74,6 +75,7 @@ async function removeUnsortedDuplicates(playlist) {
|
||||
if (channels.length !== playlist.channels.length) {
|
||||
log.print('updated')
|
||||
playlist.channels = channels
|
||||
playlist.updated = true
|
||||
}
|
||||
|
||||
return playlist
|
||||
|
Loading…
Reference in New Issue
Block a user