epg-grabber 0.25.2 → 0.25.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils.js +4 -2
- package/tests/utils.test.js +22 -0
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -220,13 +220,15 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
|
|
220
220
|
output += '</tv>'
|
|
221
221
|
|
|
222
222
|
function createXMLTVNS(s, e) {
|
|
223
|
-
if (!s
|
|
223
|
+
if (!s && !e) return null
|
|
224
|
+
s = s || 1
|
|
224
225
|
|
|
225
226
|
return `${s - 1}.${e - 1}.0/1`
|
|
226
227
|
}
|
|
227
228
|
|
|
228
229
|
function createOnScreen(s, e) {
|
|
229
|
-
if (!s
|
|
230
|
+
if (!s && !e) return null
|
|
231
|
+
s = s || 1
|
|
230
232
|
|
|
231
233
|
s = padStart(s, 2, '0')
|
|
232
234
|
e = padStart(e, 2, '0')
|
package/tests/utils.test.js
CHANGED
|
@@ -73,6 +73,28 @@ it('can convert object to xmltv string', () => {
|
|
|
73
73
|
)
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
it('can convert object to xmltv string without season number', () => {
|
|
77
|
+
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
|
78
|
+
const { channels } = utils.parseChannels(file)
|
|
79
|
+
const programs = [
|
|
80
|
+
{
|
|
81
|
+
title: 'Program 1',
|
|
82
|
+
description: 'Description for Program 1',
|
|
83
|
+
start: 1616133600,
|
|
84
|
+
stop: 1616135400,
|
|
85
|
+
category: 'Test',
|
|
86
|
+
episode: 239,
|
|
87
|
+
icon: 'https://example.com/images/Program1.png?x=шеллы&sid=777',
|
|
88
|
+
channel: '1TV.com',
|
|
89
|
+
lang: 'it'
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
const output = utils.convertToXMLTV({ channels, programs })
|
|
93
|
+
expect(output).toBe(
|
|
94
|
+
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category><episode-num system="xmltv_ns">0.238.0/1</episode-num><episode-num system="onscreen">S01E239</episode-num><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
|
|
76
98
|
it('can convert object to xmltv string without categories', () => {
|
|
77
99
|
const channels = [
|
|
78
100
|
{
|