epg-grabber 0.37.0 → 0.37.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/README.md +2 -2
- package/package.json +1 -1
- package/src/Channel.js +4 -37
- package/src/xmltv.js +4 -6
- package/tests/Channel.test.js +7 -4
- package/tests/index.test.js +1 -1
- package/tests/parser.test.js +12 -12
- package/tests/xmltv.test.js +4 -7
package/README.md
CHANGED
|
@@ -196,7 +196,7 @@ From each function in `config.js` you can access a `context` object containing t
|
|
|
196
196
|
|
|
197
197
|
## Program Object
|
|
198
198
|
|
|
199
|
-
|
|
|
199
|
+
| Property | Aliases | Type | Required |
|
|
200
200
|
| --------------- | -------------------------------- | ------------------------------------------------ | -------- |
|
|
201
201
|
| start | | `String` or `Number` or `Date()` | true |
|
|
202
202
|
| stop | | `String` or `Number` or `Date()` | true |
|
|
@@ -248,7 +248,7 @@ Example:
|
|
|
248
248
|
description: 'Description for Program 1',
|
|
249
249
|
date: '2022-05-06',
|
|
250
250
|
categories: ['Comedy', 'Drama'],
|
|
251
|
-
|
|
251
|
+
keywords: [
|
|
252
252
|
{ lang: 'en', value: 'physical-comedy' },
|
|
253
253
|
{ lang: 'en', value: 'romantic' }
|
|
254
254
|
],
|
package/package.json
CHANGED
package/src/Channel.js
CHANGED
|
@@ -4,15 +4,13 @@ class Channel {
|
|
|
4
4
|
constructor(c) {
|
|
5
5
|
const data = {
|
|
6
6
|
xmltv_id: c.xmltv_id,
|
|
7
|
-
|
|
8
|
-
toTextObject(text, c.lang)
|
|
9
|
-
),
|
|
7
|
+
name: c.name,
|
|
10
8
|
site: c.site || '',
|
|
11
9
|
site_id: c.site_id,
|
|
12
10
|
lang: c.lang || '',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
lcn:
|
|
11
|
+
icon: c.icon || c.logo || '',
|
|
12
|
+
url: c.url || toURL(c.site),
|
|
13
|
+
lcn: c.lcn
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
for (let key in data) {
|
|
@@ -26,34 +24,3 @@ module.exports = Channel
|
|
|
26
24
|
function toURL(site) {
|
|
27
25
|
return site ? `https://${site}` : ''
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
function toTextObject(text, lang) {
|
|
31
|
-
if (typeof text === 'string') {
|
|
32
|
-
return { value: text, lang }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
value: text.value,
|
|
37
|
-
lang: text.lang
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function toIconObject(icon) {
|
|
42
|
-
if (!icon) return { src: '' }
|
|
43
|
-
if (typeof icon === 'string') return { src: icon }
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
src: icon.src,
|
|
47
|
-
width: icon.width,
|
|
48
|
-
height: icon.height
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function toUrlObject(url) {
|
|
53
|
-
if (typeof url === 'string') return { system: '', value: url }
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
system: url.system || '',
|
|
57
|
-
value: url.value || ''
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/xmltv.js
CHANGED
|
@@ -30,12 +30,10 @@ function createElements(channels, programs, date) {
|
|
|
30
30
|
return (
|
|
31
31
|
'\r\n' +
|
|
32
32
|
el('channel', { id: channel.xmltv_id }, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
),
|
|
36
|
-
|
|
37
|
-
...channel.urls.map(createURLElement),
|
|
38
|
-
...channel.lcn.map(lcn => el('lcn', {}, [escapeString(lcn.value)]))
|
|
33
|
+
el('display-name', {}, [escapeString(channel.name)]),
|
|
34
|
+
el('icon', { src: channel.icon }),
|
|
35
|
+
el('url', {}, [escapeString(channel.url)]),
|
|
36
|
+
el('lcn', {}, [escapeString(channel.lcn)])
|
|
39
37
|
])
|
|
40
38
|
)
|
|
41
39
|
}),
|
package/tests/Channel.test.js
CHANGED
|
@@ -7,16 +7,19 @@ it('can create new Channel', () => {
|
|
|
7
7
|
site_id: '1',
|
|
8
8
|
site: 'example.com',
|
|
9
9
|
lang: 'fr',
|
|
10
|
-
|
|
10
|
+
url: 'https://example.com',
|
|
11
|
+
logo: 'https://example.com/logos/1TV.png',
|
|
12
|
+
lcn: 36
|
|
11
13
|
})
|
|
12
14
|
|
|
13
15
|
expect(channel).toMatchObject({
|
|
14
|
-
|
|
16
|
+
name: '1 TV',
|
|
15
17
|
xmltv_id: '1TV.com',
|
|
16
18
|
site_id: '1',
|
|
17
19
|
site: 'example.com',
|
|
18
|
-
|
|
20
|
+
url: 'https://example.com',
|
|
19
21
|
lang: 'fr',
|
|
20
|
-
|
|
22
|
+
icon: 'https://example.com/logos/1TV.png',
|
|
23
|
+
lcn: 36
|
|
21
24
|
})
|
|
22
25
|
})
|
package/tests/index.test.js
CHANGED
|
@@ -114,7 +114,7 @@ it('can mock epg grabber', done => {
|
|
|
114
114
|
site: 'example.com',
|
|
115
115
|
url: 'http://example.com/20210319/1tv.json',
|
|
116
116
|
parser: ({ channel, date }) => [
|
|
117
|
-
{ title: `Test (${channel.
|
|
117
|
+
{ title: `Test (${channel.name})`, start: '2021-03-19T04:30:00.000Z' }
|
|
118
118
|
]
|
|
119
119
|
}
|
|
120
120
|
const channel = new Channel({
|
package/tests/parser.test.js
CHANGED
|
@@ -17,16 +17,16 @@ it('can parse channels.xml', () => {
|
|
|
17
17
|
site_id: '1',
|
|
18
18
|
xmltv_id: '1TV.com',
|
|
19
19
|
lang: 'fr',
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
icon: 'https://example.com/logos/1TV.png',
|
|
21
|
+
name: '1 TV'
|
|
22
22
|
})
|
|
23
23
|
expect(channels[1]).toMatchObject({
|
|
24
24
|
site: 'example.com',
|
|
25
25
|
site_id: '2',
|
|
26
26
|
lang: '',
|
|
27
|
-
|
|
27
|
+
icon: '',
|
|
28
28
|
xmltv_id: '2TV.com',
|
|
29
|
-
|
|
29
|
+
name: '2 TV'
|
|
30
30
|
})
|
|
31
31
|
})
|
|
32
32
|
|
|
@@ -44,16 +44,16 @@ it('can parse channels.xml with inline site attribute', () => {
|
|
|
44
44
|
site_id: '1',
|
|
45
45
|
xmltv_id: '1TV.com',
|
|
46
46
|
lang: 'fr',
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
icon: 'https://example.com/logos/1TV.png',
|
|
48
|
+
name: '1 TV'
|
|
49
49
|
})
|
|
50
50
|
expect(channels[1]).toMatchObject({
|
|
51
51
|
site: 'example.com',
|
|
52
52
|
site_id: '2',
|
|
53
53
|
lang: '',
|
|
54
|
-
|
|
54
|
+
icon: '',
|
|
55
55
|
xmltv_id: '2TV.com',
|
|
56
|
-
|
|
56
|
+
name: '2 TV'
|
|
57
57
|
})
|
|
58
58
|
})
|
|
59
59
|
|
|
@@ -69,16 +69,16 @@ it('can parse legacy channels.xml', () => {
|
|
|
69
69
|
site_id: '1',
|
|
70
70
|
xmltv_id: '1TV.com',
|
|
71
71
|
lang: 'fr',
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
icon: 'https://example.com/logos/1TV.png',
|
|
73
|
+
name: '1 TV'
|
|
74
74
|
})
|
|
75
75
|
expect(channels[1]).toMatchObject({
|
|
76
76
|
site: 'example.com',
|
|
77
77
|
site_id: '2',
|
|
78
78
|
lang: '',
|
|
79
|
-
|
|
79
|
+
icon: '',
|
|
80
80
|
xmltv_id: '2TV.com',
|
|
81
|
-
|
|
81
|
+
name: '2 TV'
|
|
82
82
|
})
|
|
83
83
|
})
|
|
84
84
|
|
package/tests/xmltv.test.js
CHANGED
|
@@ -9,12 +9,9 @@ const channels = [
|
|
|
9
9
|
xmltv_id: '1TV.co',
|
|
10
10
|
name: '1 TV',
|
|
11
11
|
site: 'example.com',
|
|
12
|
-
icon:
|
|
13
|
-
url:
|
|
14
|
-
|
|
15
|
-
{ system: 'other_system', value: 'https://example.com/channel_one_alternate' }
|
|
16
|
-
],
|
|
17
|
-
lcn: [{ value: '36' }]
|
|
12
|
+
icon: 'https://example.com/channel_one_icon.jpg',
|
|
13
|
+
url: 'https://example.com/channel_one',
|
|
14
|
+
lcn: 36
|
|
18
15
|
}),
|
|
19
16
|
new Channel({
|
|
20
17
|
xmltv_id: '2TV.co',
|
|
@@ -170,6 +167,6 @@ it('can generate xmltv', () => {
|
|
|
170
167
|
const output = xmltv.generate({ channels, programs })
|
|
171
168
|
|
|
172
169
|
expect(output).toBe(
|
|
173
|
-
'<?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"
|
|
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</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 start="20080711000000" channel="channel-two.tv"/><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</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
171
|
)
|
|
175
172
|
})
|