epg-grabber 0.39.2 → 0.40.1
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/Channel.js +2 -1
- package/src/index.d.ts +2 -0
- package/src/parser.js +2 -1
- package/tests/Channel.test.js +4 -2
- package/tests/__data__/input/example.channels.xml +1 -1
- package/tests/__data__/output/duplicates.guide.xml +6 -0
- package/tests/parser.test.js +5 -2
- package/tests/__data__/output/guide.xml +0 -10
package/package.json
CHANGED
package/src/Channel.js
CHANGED
package/src/index.d.ts
CHANGED
package/src/parser.js
CHANGED
|
@@ -25,11 +25,12 @@ function parseChannels(xml) {
|
|
|
25
25
|
|
|
26
26
|
const channels = channelsTag.elements
|
|
27
27
|
.filter(el => el.name === 'channel')
|
|
28
|
-
.map(el => {
|
|
28
|
+
.map((el, index) => {
|
|
29
29
|
const c = el.attributes
|
|
30
30
|
if (!Array.isArray(el.elements)) return
|
|
31
31
|
c.name = el.elements.find(el => el.type === 'text').text
|
|
32
32
|
c.site = c.site || rootSite
|
|
33
|
+
c.index = index
|
|
33
34
|
if (!c.name) return
|
|
34
35
|
|
|
35
36
|
return new Channel(c)
|
package/tests/Channel.test.js
CHANGED
|
@@ -9,7 +9,8 @@ it('can create new Channel', () => {
|
|
|
9
9
|
lang: 'fr',
|
|
10
10
|
url: 'https://example.com',
|
|
11
11
|
logo: 'https://example.com/logos/1TV.png',
|
|
12
|
-
lcn: 36
|
|
12
|
+
lcn: 36,
|
|
13
|
+
index: 2
|
|
13
14
|
})
|
|
14
15
|
|
|
15
16
|
expect(channel).toMatchObject({
|
|
@@ -20,6 +21,7 @@ it('can create new Channel', () => {
|
|
|
20
21
|
url: 'https://example.com',
|
|
21
22
|
lang: 'fr',
|
|
22
23
|
icon: 'https://example.com/logos/1TV.png',
|
|
23
|
-
lcn: 36
|
|
24
|
+
lcn: 36,
|
|
25
|
+
index: 2
|
|
24
26
|
})
|
|
25
27
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<channels site="example.com">
|
|
3
|
-
<channel xmltv_id="1TV.com" site_id="1" lang="fr" logo="https://example.com/logos/1TV.png">1 TV</channel>
|
|
3
|
+
<channel xmltv_id="1TV.com" site_id="1" lang="fr" logo="https://example.com/logos/1TV.png" lcn="36">1 TV</channel>
|
|
4
4
|
<channel xmltv_id="2TV.com" site_id="2">2 TV</channel>
|
|
5
5
|
<channel xmltv_id="3TV.com" site_id="3"></channel>
|
|
6
6
|
</channels>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?><tv date="20250716">
|
|
2
|
+
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url><lcn>36</lcn></channel>
|
|
3
|
+
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
|
+
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
|
|
5
|
+
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="2TV.com"><title>Program1</title></programme>
|
|
6
|
+
</tv>
|
package/tests/parser.test.js
CHANGED
|
@@ -18,7 +18,9 @@ it('can parse channels.xml', () => {
|
|
|
18
18
|
xmltv_id: '1TV.com',
|
|
19
19
|
lang: 'fr',
|
|
20
20
|
icon: 'https://example.com/logos/1TV.png',
|
|
21
|
-
name: '1 TV'
|
|
21
|
+
name: '1 TV',
|
|
22
|
+
index: 0,
|
|
23
|
+
lcn: 36
|
|
22
24
|
})
|
|
23
25
|
expect(channels[1]).toMatchObject({
|
|
24
26
|
site: 'example.com',
|
|
@@ -26,7 +28,8 @@ it('can parse channels.xml', () => {
|
|
|
26
28
|
lang: '',
|
|
27
29
|
icon: '',
|
|
28
30
|
xmltv_id: '2TV.com',
|
|
29
|
-
name: '2 TV'
|
|
31
|
+
name: '2 TV',
|
|
32
|
+
index: 1
|
|
30
33
|
})
|
|
31
34
|
})
|
|
32
35
|
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?><tv date="20250715">
|
|
2
|
-
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>
|
|
3
|
-
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
|
-
<channel id="3TV.com"><display-name>3 TV</display-name><url>https://example2.com</url></channel>
|
|
5
|
-
<channel id="4TV.com"><display-name>4 TV</display-name><url>https://example2.com</url></channel>
|
|
6
|
-
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="1TV.com"><title lang="fr">Program1</title></programme>
|
|
7
|
-
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="4TV.com"><title>Program1</title></programme>
|
|
8
|
-
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="3TV.com"><title>Program1</title></programme>
|
|
9
|
-
<programme start="20220101000000 +0000" stop="20220101010000 +0000" channel="2TV.com"><title>Program1</title></programme>
|
|
10
|
-
</tv>
|