mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00

Test: ```sh npm test -- tv.nu > test > run-script-os tv.nu > test:win32 > SET "TZ=Pacific/Nauru" && npx jest --runInBand tv.nu PASS sites/tv.nu/tv.nu.test.js (6.72 s) √ can generate valid url (5 ms) √ can parse response (7 ms) √ can handle empty guide (1 ms) Test Suites: 1 passed, 1 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 7.246 s Ran all test suites matching /tv.nu/i. ``` Grab: ```sh npm run grab -- --site=tv.nu > grab > npx tsx scripts/commands/epg/grab.ts --site=tv.nu starting... config: output: guide.xml maxConnections: 1 gzip: false site: tv.nu loading channels... found 199 channel(s) run #1: [1/398] tv.nu (da) - dk4.dk - Dec 4, 2024 (41 programs) [2/398] tv.nu (da) - dk4.dk - Dec 5, 2024 (43 programs) ... [397/398] tv.nu (sv) - VSportUltraHD.se - Dec 4, 2024 (7 programs) [398/398] tv.nu (sv) - VSportUltraHD.se - Dec 5, 2024 (7 programs) saving to "guide.xml"... done in 00h 02m 40s ``` Signed-off-by: Toha <tohenk@yahoo.com>
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const { parser, url } = require('./tv.nu.config.js')
|
|
const dayjs = require('dayjs')
|
|
const utc = require('dayjs/plugin/utc')
|
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
dayjs.extend(customParseFormat)
|
|
dayjs.extend(utc)
|
|
|
|
const date = dayjs.utc('2024-12-03', 'YYYY-MM-DD').startOf('d')
|
|
const channel = {
|
|
site_id: '3sat',
|
|
xmltv_id: '3sat.de'
|
|
}
|
|
|
|
it('can generate valid url', () => {
|
|
expect(url({ channel, date })).toBe(
|
|
'https://web-api.tv.nu/channels/3sat/schedule?date=2024-12-03&fullDay=true'
|
|
)
|
|
})
|
|
|
|
it('can parse response', () => {
|
|
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
|
|
const result = parser({ content }).map(p => {
|
|
p.start = p.start.toJSON()
|
|
p.stop = p.stop.toJSON()
|
|
return p
|
|
})
|
|
|
|
expect(result).toMatchObject([
|
|
{
|
|
start: '2024-12-03T11:50:00.000Z',
|
|
stop: '2024-12-03T12:15:00.000Z',
|
|
title: 'Natur im Garten',
|
|
description:
|
|
'Der Gartenbuchautor Karl Ploberger gibt in der Sendung Tipps und Tricks zur Gartenpflege.',
|
|
category: ['Konsument', 'Underhållning', 'Trädgård'],
|
|
season: 29,
|
|
episode: 9
|
|
}
|
|
])
|
|
})
|
|
|
|
it('can handle empty guide', () => {
|
|
const content = fs.readFileSync(path.join(__dirname, '__data__', 'no_content.json'))
|
|
const result = parser({ content })
|
|
expect(result).toMatchObject([])
|
|
})
|