diff --git a/scripts/clean.js b/scripts/clean.js index cb5ecced2..6b372cf2a 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -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 diff --git a/scripts/detect-resolution.js b/scripts/detect-resolution.js index 57c33267c..5c01841f5 100644 --- a/scripts/detect-resolution.js +++ b/scripts/detect-resolution.js @@ -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 diff --git a/scripts/format.js b/scripts/format.js index b687eed2f..0fa233f3f 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -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 diff --git a/scripts/helpers/Playlist.js b/scripts/helpers/Playlist.js index 5b26b4ac2..aaaf676ff 100644 --- a/scripts/helpers/Playlist.js +++ b/scripts/helpers/Playlist.js @@ -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()) } } } diff --git a/scripts/remove-duplicates.js b/scripts/remove-duplicates.js index f2d62e919..650fbab47 100644 --- a/scripts/remove-duplicates.js +++ b/scripts/remove-duplicates.js @@ -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