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

Test: ```sh npm test --- digiturk.com.tr > test > run-script-os digiturk.com.tr > test:win32 > SET "TZ=Pacific/Nauru" && npx jest --runInBand digiturk.com.tr PASS sites/digiturk.com.tr/digiturk.com.tr.test.js √ can generate valid url (3 ms) √ can parse response (167 ms) √ can handle empty guide (1 ms) Test Suites: 1 passed, 1 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 0.918 s, estimated 1 s Ran all test suites matching /digiturk.com.tr/i. ``` Grab: ```sh npm run grab --- --site=digiturk.com.tr > grab > npx tsx scripts/commands/epg/grab.ts --site=digiturk.com.tr starting... config: output: guide.xml maxConnections: 1 gzip: false site: digiturk.com.tr loading channels... found 108 channel(s) run #1: [1/216] digiturk.com.tr (tr) - 212 - Jan 12, 2025 (56 programs) [2/216] digiturk.com.tr (tr) - 212 - Jan 13, 2025 (58 programs) ... [215/216] digiturk.com.tr (tr) - VavTV.tr - Jan 13, 2025 (18 programs) [216/216] digiturk.com.tr (tr) - TVNET.tr - Jan 13, 2025 (32 programs) saving to "guide.xml"... done in 00h 02m 10s ``` Signed-off-by: Toha <tohenk@yahoo.com>
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
const { parser, url } = require('./digiturk.com.tr.config.js')
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
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('2025-01-12', 'YYYY-MM-DD').startOf('d')
|
|
const channel = {
|
|
site_id: '351',
|
|
xmltv_id: 'Nickelodeon.tr'
|
|
}
|
|
|
|
it('can generate valid url', () => {
|
|
const result = url({ date, channel })
|
|
expect(result).toBe(
|
|
'https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=01%2F12%2F2025+00%3A00%3A00'
|
|
)
|
|
})
|
|
|
|
it('can parse response', () => {
|
|
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
|
|
const results = parser({ content, channel, date }).map(p => {
|
|
p.start = p.start.toJSON()
|
|
p.stop = p.stop.toJSON()
|
|
return p
|
|
})
|
|
|
|
expect(results.length).toBe(57)
|
|
expect(results[0]).toMatchObject({
|
|
start: '2025-01-11T21:00:00.000Z',
|
|
stop: '2025-01-11T21:25:00.000Z',
|
|
title: 'Sünger Bob Kare Pantolon'
|
|
})
|
|
expect(results[56]).toMatchObject({
|
|
start: '2025-01-12T17:40:00.000Z',
|
|
stop: '2025-01-12T18:00:00.000Z',
|
|
title: 'Casagrande Ailesi'
|
|
})
|
|
})
|
|
|
|
it('can handle empty guide', () => {
|
|
const result = parser({ content: '', channel, date })
|
|
expect(result).toMatchObject([])
|
|
})
|