mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
skylink.au
Updated config and tests
This commit is contained in:
parent
2f6283a45a
commit
2140dbb442
5 changed files with 57 additions and 44 deletions
13
sites/skylink.cz/__data__/content.html
Normal file
13
sites/skylink.cz/__data__/content.html
Normal file
File diff suppressed because one or more lines are too long
1
sites/skylink.cz/__data__/no_content.html
Normal file
1
sites/skylink.cz/__data__/no_content.html
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?><tv-program-programmes></tv-program-programmes>
|
|
@ -2,11 +2,11 @@ const dayjs = require('dayjs')
|
|||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
var convert = require('xml-js');
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
const tz = 'Europe/Prague'
|
||||
|
||||
module.exports = {
|
||||
site: 'skylink.cz',
|
||||
|
@ -19,12 +19,12 @@ module.exports = {
|
|||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.name,
|
||||
start: parseTime(item.startDate),
|
||||
stop: parseTime(item.endDate),
|
||||
description: item.longDescription || item.shortDescription,
|
||||
title: item.name._text,
|
||||
start: parseTime(item.startDate._text),
|
||||
stop: parseTime(item.endDate._text),
|
||||
description: parseDescription(item),
|
||||
category: parseCategory(item),
|
||||
date: item.year || null,
|
||||
date: item.year._text || null,
|
||||
director: parseList(item.directors),
|
||||
actor: parseList(item.actors)
|
||||
})
|
||||
|
@ -35,23 +35,31 @@ module.exports = {
|
|||
|
||||
function parseItems(content) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
const data = convert.xml2js(content, {compact: true, ignoreDeclaration: true, ignoreAttributes:true})
|
||||
if (!data) return []
|
||||
const programmes = data['tv-program-programmes']
|
||||
const programmes = data['tv-program-programmes'].programme
|
||||
return programmes && Array.isArray(programmes) ? programmes : []
|
||||
} catch (err) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
function parseDescription(item) {
|
||||
if (item.longDescription) return item.longDescription._text
|
||||
if (item.shortDescription) return item.shortDescription._text
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
function parseList(list) {
|
||||
return typeof list === 'string' ? list.split(',') : []
|
||||
if (!list) return []
|
||||
if (!list._text) return []
|
||||
return typeof list._text === 'string' ? list._text.split(', ') : []
|
||||
}
|
||||
function parseTime(time) {
|
||||
return dayjs(time, 'DD.MM.YYYY HH.mm').tz(tz)
|
||||
return dayjs.tz(time, 'DD.MM.YYYY HH.mm', 'Europe/Prague')
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
if (!item['programme-type']) return null
|
||||
return item['programme-type'].name
|
||||
return item['programme-type'].name._text
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// npx epg-grabber --config=sites/skylink.cz/skylink.cz.config.js --channels=sites/skylink.cz/skylink.cz_cz.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./skylink.cz.config.js')
|
||||
const { parser, url } = require('./skylink.cz.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
|
@ -8,8 +8,7 @@ const utc = require('dayjs/plugin/utc')
|
|||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
const axios = require('axios')
|
||||
jest.mock('axios')
|
||||
|
||||
|
||||
const channel = {
|
||||
site_id: '1',
|
||||
|
@ -27,35 +26,27 @@ it('can generate valid url for tomorrow', () => {
|
|||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const date = dayjs.utc('2022-12-23', 'YYYY-MM-DD').startOf('d')
|
||||
const content = `<?xml version="1.0" encoding="UTF-8"?><tv-program-programmes><programme><id>32288117</id><name>Čepice</name><premiere>0</premiere><widescreen>0</widescreen><stereo>0</stereo><blackWhite>0</blackWhite><subtitles>1</subtitles><hd>0</hd><fdbRating>0</fdbRating><fdbUrl>https://www.fdb.cz/film/bakalari-11-serie-13-dil-proc-ty-musis-vsechno-vyzvonit/127681</fdbUrl><shortDescription>TV film ČR (1983). O jednom netradičním vánočním překvapení. Scénář M. Najbrt. Kamera J. Plesník.</shortDescription><longDescription>Jarka (J. Bohdalová) vyčítá manželovi Jiřímu (F. Řehák), že jí nepomáhá při předvánočním úklidu. Vzápětí ale náhodou najde ve skříni ukrytou dámskou čepici a napadne ji, že jde o Jiřího dárek pro ni pod stromeček. Její chování se ihned změní. Jen muži naznačí, že by chtěla čepici jiné barvy. Manžel jí ovšem řekne, že čepici si u něj schoval kamarád Venca (M. Šulc). Zklamaná žena to prozradí Vencově manželce Božce (A. Tománková). Na Štědrý den však Božka najde pod stromečkem jen rtěnku...</longDescription><series>0</series><seriesId/><origin>CZE</origin><year>1983</year><duration>0</duration><directors>Mudra F.</directors><actors>Bohdalová J., Řehák F., Šulc M.</actors><date>23.12.2022</date><dateTimeInSec>1671750000</dateTimeInSec><startDate>23.12.2022 09:00</startDate><startDateTimeInSec>1671782400</startDateTimeInSec><startTime>09:00</startTime><endDate>23.12.2022 09:20</endDate><endDateTimeInSec>1671783600</endDateTimeInSec><endTime>09:20</endTime><pictures/><programme-type><id>3</id><name>film</name><tid>3</tid></programme-type></programme></tv-program-programmes>`
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
|
||||
let results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
expect(results[3]).toMatchObject({
|
||||
title: `Čepice`,
|
||||
description: `Jarka (J. Bohdalová) vyčítá manželovi Jiřímu (F. Řehák), že jí nepomáhá při předvánočním úklidu. Vzápětí ale náhodou najde ve skříni ukrytou dámskou čepici a napadne ji, že jde o Jiřího dárek pro ni pod stromeček. Její chování se ihned změní. Jen muži naznačí, že by chtěla čepici jiné barvy. Manžel jí ovšem řekne, že čepici si u něj schoval kamarád Venca (M. Šulc). Zklamaná žena to prozradí Vencově manželce Božce (A. Tománková). Na Štědrý den však Božka najde pod stromečkem jen rtěnku...`,
|
||||
category: 'film',
|
||||
date: '1983',
|
||||
director: ['Mudra F.'],
|
||||
actor: ['Bohdalová J.', 'Řehák F.', 'Šulc M.'],
|
||||
start: '2022-12-23T08:00:00.000Z',
|
||||
stop: '2022-12-23T08:20:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
let results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'Čepice',
|
||||
description: `Jarka (J. Bohdalová) vyčítá manželovi Jiřímu (F. Řehák), že jí nepomáhá při předvánočním úklidu. Vzápětí ale náhodou najde ve skříni ukrytou dámskou čepici a napadne ji, že jde o Jiřího dárek pro ni pod stromeček. Její chování se ihned změní. Jen muži naznačí, že by chtěla čepici jiné barvy. Manžel jí ovšem řekne, že čepici si u něj schoval kamarád Venca (M. Šulc). Zklamaná žena to prozradí Vencově manželce Božce (A. Tománková). Na Štědrý den však Božka najde pod stromečkem jen rtěnku...`,
|
||||
category: 'film',
|
||||
date: '1983',
|
||||
director: 'Mudra F.',
|
||||
actor: ['Bohdalová J.', 'Řehák F.', 'Šulc M.'],
|
||||
start: '2022-12-23T08:00:00.000Z',
|
||||
stop: '2022-12-23T08:20:00.000Z'
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser(
|
||||
{
|
||||
content: `<?xml version="1.0" encoding="UTF-8" ?><tv-program-programmes></tv-program-programmes>`
|
||||
},
|
||||
channel
|
||||
)
|
||||
expect(result).toMatchObject([])
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
const result = parser(content, channel )
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
|
@ -265,6 +265,6 @@
|
|||
<!-- <channel lang="??" xmltv_id="???" site_id="???">ZDF info HD</channel> -->
|
||||
<!-- <channel lang="??" xmltv_id="???" site_id="???">ZDF neo HD</channel> -->
|
||||
<!-- <channel lang="??" xmltv_id="???" site_id="???">Zee One HD</channel> -->
|
||||
<!-- <channel lang="??" xmltv_id="???" site_id="???">Zenebutik</channel> -->
|
||||
<channel lang="??" xmltv_id="???" site_id="???">Zenebutik</channel> -->
|
||||
</channels>
|
||||
</site>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue