epg-grabber 0.39.1 → 0.40.0
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/parser.js +2 -1
- package/src/xmltv.js +1 -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/xmltv.test.js +5 -1
- package/tests/__data__/output/guide.xml +0 -10
package/package.json
CHANGED
package/src/Channel.js
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/src/xmltv.js
CHANGED
|
@@ -209,7 +209,7 @@ function toString(elem) {
|
|
|
209
209
|
return `<${elem.name}${attrs}>${_children}</${elem.name}>`
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
if (!['
|
|
212
|
+
if (!attrs && !['previously-shown'].includes(elem.name)) return ''
|
|
213
213
|
|
|
214
214
|
return `<${elem.name}${attrs}/>`
|
|
215
215
|
}
|
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
|
|
package/tests/xmltv.test.js
CHANGED
|
@@ -19,6 +19,10 @@ const channels = [
|
|
|
19
19
|
site: 'example.com',
|
|
20
20
|
lang: 'es',
|
|
21
21
|
logo: 'https://example.com/logos/2TV.png'
|
|
22
|
+
}),
|
|
23
|
+
new Channel({
|
|
24
|
+
xmltv_id: '3TV.co',
|
|
25
|
+
name: '3 TV'
|
|
22
26
|
})
|
|
23
27
|
]
|
|
24
28
|
|
|
@@ -167,6 +171,6 @@ it('can generate xmltv', () => {
|
|
|
167
171
|
const output = xmltv.generate({ channels, programs })
|
|
168
172
|
|
|
169
173
|
expect(output).toBe(
|
|
170
|
-
'<?xml version="1.0" encoding="UTF-8" ?><tv date="20220505">\r\n<channel id="1TV.co"><display-name>1 TV</display-name><icon src="https://example.com/channel_one_icon.jpg"/><url>https://example.com/channel_one?foo=foo&bar=bar</url><lcn>36</lcn></channel>\r\n<channel id="2TV.co"><display-name>2 TV</display-name><icon src="https://example.com/logos/2TV.png"/><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.co"><title>Program 1</title><sub-title>Sub-title & 1</sub-title><desc>Description for Program 1</desc><credits><director>Director 1<url system="TestSystem">http://example.com/director1.html</url><image>https://example.com/image1.jpg</image><image type="person" size="2" orient="P" system="TestSystem">https://example.com/image2.jpg</image></director><director>Director 2</director><actor>Actor 1</actor><actor>Actor 2</actor><writer>Writer 1</writer></credits><date>20220506</date><category>Test</category><keyword lang="en">physical-comedy</keyword><keyword lang="en">romantic</keyword><language>English</language><orig-language lang="en">French</orig-language><length units="minutes">60</length><country>US</country><url>http://example.com/title.html</url><episode-num system="xmltv_ns">8.238.0/1</episode-num><episode-num system="onscreen">S09E239</episode-num><video><present>yes</present><colour>no</colour><aspect>16:9</aspect><quality>HDTV</quality></video><audio><present>yes</present><stereo>Dolby Digital</stereo></audio><previously-shown/><premiere>First time on British TV</premiere><last-chance lang="en">Last time on this channel</last-chance><new/><subtitles type="teletext"><language>English</language></subtitles><subtitles type="onscreen"><language lang="en">Spanish</language></subtitles><rating system="MPAA"><value>P&G</value><icon src="http://example.com/pg_symbol.png"/></rating><star-rating system="TV Guide"><value>4/5</value><icon src="stars.png"/></star-rating><star-rating system="IMDB"><value>8/10</value></star-rating><review type="text" source="Rotten Tomatoes" reviewer="Joe Bloggs" lang="en">This is a fantastic show!</review><review type="text" source="IDMB" reviewer="Jane Doe" lang="en">I love this show!</review><review type="url" source="Rotten Tomatoes" reviewer="Joe Bloggs" lang="en">https://example.com/programme_one_review</review><image type="poster" size="1" orient="P" system="tvdb">https://tvdb.com/programme_one_poster_1.jpg?foo=foo&bar=bar</image><image type="poster" size="2" orient="P" system="tmdb">https://tmdb.com/programme_one_poster_2.jpg</image><image type="backdrop" size="3" orient="L" system="tvdb">https://tvdb.com/programme_one_backdrop_3.jpg</image><image type="backdrop" size="3" orient="L" system="tmdb">https://tmdb.com/programme_one_backdrop_3.jpg</image><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="2TV.co"><title lang="es">Program 2</title></programme>\r\n</tv>'
|
|
174
|
+
'<?xml version="1.0" encoding="UTF-8" ?><tv date="20220505">\r\n<channel id="1TV.co"><display-name>1 TV</display-name><icon src="https://example.com/channel_one_icon.jpg"/><url>https://example.com/channel_one?foo=foo&bar=bar</url><lcn>36</lcn></channel>\r\n<channel id="2TV.co"><display-name>2 TV</display-name><icon src="https://example.com/logos/2TV.png"/><url>https://example.com</url></channel>\r\n<channel id="3TV.co"><display-name>3 TV</display-name></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.co"><title>Program 1</title><sub-title>Sub-title & 1</sub-title><desc>Description for Program 1</desc><credits><director>Director 1<url system="TestSystem">http://example.com/director1.html</url><image>https://example.com/image1.jpg</image><image type="person" size="2" orient="P" system="TestSystem">https://example.com/image2.jpg</image></director><director>Director 2</director><actor>Actor 1</actor><actor>Actor 2</actor><writer>Writer 1</writer></credits><date>20220506</date><category>Test</category><keyword lang="en">physical-comedy</keyword><keyword lang="en">romantic</keyword><language>English</language><orig-language lang="en">French</orig-language><length units="minutes">60</length><country>US</country><url>http://example.com/title.html</url><episode-num system="xmltv_ns">8.238.0/1</episode-num><episode-num system="onscreen">S09E239</episode-num><video><present>yes</present><colour>no</colour><aspect>16:9</aspect><quality>HDTV</quality></video><audio><present>yes</present><stereo>Dolby Digital</stereo></audio><previously-shown/><premiere>First time on British TV</premiere><last-chance lang="en">Last time on this channel</last-chance><new/><subtitles type="teletext"><language>English</language></subtitles><subtitles type="onscreen"><language lang="en">Spanish</language></subtitles><rating system="MPAA"><value>P&G</value><icon src="http://example.com/pg_symbol.png"/></rating><star-rating system="TV Guide"><value>4/5</value><icon src="stars.png"/></star-rating><star-rating system="IMDB"><value>8/10</value></star-rating><review type="text" source="Rotten Tomatoes" reviewer="Joe Bloggs" lang="en">This is a fantastic show!</review><review type="text" source="IDMB" reviewer="Jane Doe" lang="en">I love this show!</review><review type="url" source="Rotten Tomatoes" reviewer="Joe Bloggs" lang="en">https://example.com/programme_one_review</review><image type="poster" size="1" orient="P" system="tvdb">https://tvdb.com/programme_one_poster_1.jpg?foo=foo&bar=bar</image><image type="poster" size="2" orient="P" system="tmdb">https://tmdb.com/programme_one_poster_2.jpg</image><image type="backdrop" size="3" orient="L" system="tvdb">https://tvdb.com/programme_one_backdrop_3.jpg</image><image type="backdrop" size="3" orient="L" system="tmdb">https://tmdb.com/programme_one_backdrop_3.jpg</image><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="2TV.co"><title lang="es">Program 2</title></programme>\r\n</tv>'
|
|
171
175
|
)
|
|
172
176
|
})
|
|
@@ -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><icon/><url>https://example.com</url></channel>
|
|
4
|
-
<channel id="3TV.com"><display-name>3 TV</display-name><icon/><url>https://example2.com</url></channel>
|
|
5
|
-
<channel id="4TV.com"><display-name>4 TV</display-name><icon/><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>
|