Files
epg/sites/tvplus.com.tr/tvplus.com.tr.test.js
Toha 458cac0894 Update tvplus.com.tr guide.
Test:

```sh
npm test -- tvplus.com.tr

> test
> run-script-os tvplus.com.tr

> test:win32
> SET "TZ=Pacific/Nauru" && npx jest --runInBand tvplus.com.tr

 PASS  sites/tvplus.com.tr/tvplus.com.tr.test.js
  √ can generate valid url (4 ms)
  √ can parse response (15 ms)
  √ can handle empty guide

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        3.648 s, estimated 4 s
Ran all test suites matching /tvplus.com.tr/i.
```

Grab:

```sh
npm run grab -- --site=tvplus.com.tr

> grab
> npx tsx scripts/commands/epg/grab.ts --site=tvplus.com.tr

starting...
config:
  output: guide.xml
  maxConnections: 1
  gzip: false
  site: tvplus.com.tr
loading channels...
  found 10 channel(s)
run #1:
  [1/20] tvplus.com.tr (tr) - 24TV.tr - Dec 15, 2024 (22 programs)
  [2/20] tvplus.com.tr (tr) - 24TV.tr - Dec 16, 2024 (19 programs)
  [3/20] tvplus.com.tr (tr) - BabyTV.uk - Dec 16, 2024 (48 programs)
  [4/20] tvplus.com.tr (tr) - BabyTV.uk - Dec 15, 2024 (48 programs)
  [5/20] tvplus.com.tr (tr) - ASpor.tr - Dec 16, 2024 (13 programs)
  [6/20] tvplus.com.tr (tr) - ASpor.tr - Dec 15, 2024 (14 programs)
  [7/20] tvplus.com.tr (tr) - APara.tr - Dec 16, 2024 (31 programs)
  [8/20] tvplus.com.tr (tr) - APara.tr - Dec 15, 2024 (25 programs)
  [9/20] tvplus.com.tr (tr) - AlJazeeraEnglish.qa - Dec 16, 2024 (32 programs)
  [10/20] tvplus.com.tr (tr) - AlJazeeraEnglish.qa - Dec 15, 2024 (32 programs)
  [11/20] tvplus.com.tr (tr) - AlJazeera.qa - Dec 16, 2024 (40 programs)
  [12/20] tvplus.com.tr (tr) - AlJazeera.qa - Dec 15, 2024 (41 programs)
  [13/20] tvplus.com.tr (tr) - AkitTV.tr - Dec 16, 2024 (15 programs)
  [14/20] tvplus.com.tr (tr) - AkitTV.tr - Dec 15, 2024 (12 programs)
  [15/20] tvplus.com.tr (tr) - AHaber.tr - Dec 16, 2024 (27 programs)
  [16/20] tvplus.com.tr (tr) - AHaber.tr - Dec 15, 2024 (19 programs)
  [17/20] tvplus.com.tr (tr) - A2TV.tr - Dec 16, 2024 (11 programs)
  [18/20] tvplus.com.tr (tr) - A2TV.tr - Dec 15, 2024 (11 programs)
  [19/20] tvplus.com.tr (tr) - 360.tr - Dec 16, 2024 (18 programs)
  [20/20] tvplus.com.tr (tr) - 360.tr - Dec 15, 2024 (18 programs)
  saving to "guide.xml"...
  done in 00h 02m 17s
```

Signed-off-by: Toha <tohenk@yahoo.com>
2024-12-17 08:54:11 +07:00

77 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { parser, url } = require('./tvplus.com.tr.config.js')
const fs = require('fs')
const path = require('path')
const axios = require('axios')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
jest.mock('axios')
const date = dayjs.utc('2024-12-15', 'YYYY-MM-DD').startOf('d')
const channel = {
lang: 'tr',
site_id: 'nick-jr/4353',
xmltv_id: 'NickJr.tr'
}
axios.get.mockImplementation((url, opts) => {
if (url === 'https://tvplus.com.tr/canli-tv/yayin-akisi') {
return Promise.resolve({
data: fs.readFileSync(path.join(__dirname, '__data__', 'build.html')).toString()
})
}
})
it('can generate valid url', async () => {
expect(await url({ channel })).toBe('https://tvplus.com.tr/_next/data/kUzvz_bbQJNaShlFUkrR3/tr/canli-tv/yayin-akisi/nick-jr--4353.json?title=nick-jr--4353')
})
it('can parse response', () => {
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
const results = parser({ date, channel, content })
.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(88)
expect(results[0]).toMatchObject({
start: '2024-12-14T21:10:00.000Z',
stop: '2024-12-14T21:20:00.000Z',
title: 'Camgöz (2020)',
description:
'Max\'in Camgöz adında yarı köpek balığı yarı köpek eşsiz bir evcil havyanı vardır. İlk başlarda Camgöz\'ü saklamaya çalışsa da Sisli Pınarlar\'da, en iyi arkadaşlar, meraklı komşular ve hatta Max\'in ailesi bile yaramaz yeni arkadaşını fark edecektir.',
image:
'https://gbzeottvsc01.tvplus.com.tr:33207/CPS/images/universal/film/program/202412/20241209/21/2126356250845eb88428_0_XL.jpg',
category: 'Çocuk',
season: 1,
episode: 116
})
expect(results[10]).toMatchObject({
start: '2024-12-14T23:00:00.000Z',
stop: '2024-12-14T23:25:00.000Z',
title: 'Blaze ve Yol Canavarları',
description:
'Blaze ve Yol Canavarları, dünyanın en büyük canavar kamyonu Blaze ve en iyi arkadaşı ve sürücüsü AJ adında bir çocuk hakkındaki interaktif bir anaokulu animasyon dizisidir.',
image:
'https://gbzeottvsc01.tvplus.com.tr:33207/CPS/images/universal/film/program/202412/20241209/94/2126356271145eb88428_0_XL.jpg',
category: 'Çocuk',
season: 6,
episode: 617
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: ''
})
expect(result).toMatchObject([])
})