diff --git a/scripts/format.js b/scripts/format.js index 22c633d38..3a669d0d4 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -61,7 +61,7 @@ async function updatePlaylist(playlist) { } for (const channel of playlist.channels) { - addMissingData(channel) + addMissingData(channel, playlist) updateGroupTitle(channel) normalizeUrl(channel) @@ -122,7 +122,8 @@ function updateStatus(channel, status) { } } -function addMissingData(channel) { +function addMissingData(channel, playlist) { + const code = playlist.country.code // tvg-name if (!channel.tvg.name && channel.name) { channel.tvg.name = channel.name.replace(/\"/gi, '') diff --git a/scripts/helpers/db.js b/scripts/helpers/db.js index f94ce678a..52f537098 100644 --- a/scripts/helpers/db.js +++ b/scripts/helpers/db.js @@ -211,10 +211,10 @@ db.playlists = { return this.list }, only(list = []) { - return this.list.filter(playlist => list.includes(playlist.name)) + return this.list.filter(playlist => list.includes(playlist.filename)) }, except(list = []) { - return this.list.filter(playlist => !list.includes(playlist.name)) + return this.list.filter(playlist => !list.includes(playlist.filename)) }, sortBy(fields) { this.list = utils.sortBy(this.list, fields) diff --git a/scripts/helpers/parser.js b/scripts/helpers/parser.js index 815c819ec..98f315c16 100644 --- a/scripts/helpers/parser.js +++ b/scripts/helpers/parser.js @@ -15,10 +15,13 @@ parser.parseIndex = function () { parser.parsePlaylist = async function (url) { const content = file.read(url) const result = playlistParser.parse(content) - const name = file.getFilename(url) - const country = utils.code2name(name) + const filename = file.getFilename(url) + const country = { + code: filename, + name: utils.code2name(filename) + } - return new Playlist({ header: result.header, items: result.items, url, country, name }) + return new Playlist({ header: result.header, items: result.items, url, filename, country }) } module.exports = parser