From faa40e5a777af2237e79a71abe79c22294c02cb1 Mon Sep 17 00:00:00 2001 From: freearhey Date: Tue, 13 Apr 2021 23:28:09 +0300 Subject: [PATCH] Added support of program icons Resolve #1 --- README.md | 1 + src/utils.js | 7 ++++++- tests/utils.test.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd367f2..2a7c1a5 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ module.exports = { stop, // program end time (optional) description, // program description (optional) category, // program category (optional) + icon, // program icon (optional) lang // program language (default: 'en') }, ... diff --git a/src/utils.js b/src/utils.js index b3785cf..9051b3d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -117,7 +117,7 @@ utils.convertToXMLTV = function ({ config, channels, programs }) { output += `${displayName}` if (channel.logo) { const logo = this.escapeString(channel.logo) - output += `` + output += `` } output += `\r\n` } @@ -132,6 +132,7 @@ utils.convertToXMLTV = function ({ config, channels, programs }) { const start = program.start ? dayjs.utc(program.start).format('YYYYMMDDHHmmss ZZ') : '' const stop = program.stop ? dayjs.utc(program.stop).format('YYYYMMDDHHmmss ZZ') : '' const lang = program.lang || config.lang + const icon = program.icon if (start && title) { output += `${category}` } + if (icon) { + output += `` + } + output += '\r\n' } } diff --git a/tests/utils.test.js b/tests/utils.test.js index 961fa27..59615b1 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -55,13 +55,14 @@ it('can convert object to xmltv string', () => { start: '2021-03-19 06:00:00 +0000', stop: '2021-03-19 06:30:00 +0000', category: 'Test', + icon: 'https://example.com/images/Program1.png', channel: '1TV.com', lang: 'it' } ] const output = utils.convertToXMLTV({ channels, programs }) expect(output).toBe( - '\r\n1 TV\r\n2 TV\r\nProgram 1Description for Program 1Test\r\n' + '\r\n1 TV\r\n2 TV\r\nProgram 1Description for Program 1Test\r\n' ) })