From 67dc65a43487b308321f351456008c8c093eb0d7 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 16 Aug 2021 12:35:13 +0300 Subject: [PATCH] Fixes "formatter doesn't fill tags" issue #4097 --- scripts/format.js | 5 +++-- scripts/helpers/db.js | 4 ++-- scripts/helpers/parser.js | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/format.js b/scripts/format.js index 22c633d385..3a669d0d40 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 f94ce678a1..52f5370986 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 815c819ec0..98f315c168 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