Update tvarenasport.com guide.

Test:

```sh
npm test -- tvarenasport.com

> test
> run-script-os tvarenasport.com

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

 PASS  sites/tvarenasport.com/tvarenasport.com.test.js (5.89 s)
  √ can parse response (977 ms)
  √ can handle empty guide

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        6.097 s
Ran all test suites matching /tvarenasport.com/i.
```

Grab:

```sh
npm run grab -- --site=tvarenasport.com

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

starting...
config:
  output: guide.xml
  maxConnections: 1
  gzip: false
  site: tvarenasport.com
loading channels...
  found 14 channel(s)
run #1:
  [1/28] tvarenasport.com (sr) - ArenaSport1.rs - Dec 7, 2024 (16 programs)
  [2/28] tvarenasport.com (sr) - ArenaSport1.rs - Dec 8, 2024 (14 programs)
  ...
  [27/28] tvarenasport.com (sr) - ArenaSport1Premium.rs - Dec 8, 2024 (17 programs)
  [28/28] tvarenasport.com (sr) - ArenaSport1Premium.rs - Dec 7, 2024 (19 programs)
  saving to "guide.xml"...
  done in 00h 00m 29s
```

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha
2024-12-07 17:07:29 +07:00
parent ce4f3e6935
commit 34da0a19eb
4 changed files with 21106 additions and 61 deletions
+22 -20
View File
@@ -1,45 +1,47 @@
const { parser, url } = require('./tvarenasport.com.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('2021-11-17', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2024-12-07', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '380',
xmltv_id: 'ArenaSport1.rs'
site_id: 'a1p',
xmltv_id: 'ArenaSport1Premium.rs'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.tvarenasport.com/api/schedule?date=17-11-2021')
})
it('can parse response', () => {
const content =
'{"items":[{"id":2857,"title":"Crvena zvezda mts - Partizan NIS","start":"2021-11-16T23:30:00Z","end":"2021-11-17T01:30:00Z","sport":"ABA LIGA","league":"Ko\u0161arka","group":"380","isLive":false,"doNotMiss":false,"domain":"srb"},{"id":3155,"title":"Sao Paulo - Flamengo","start":"2021-11-17T00:00:00Z","end":"2021-11-17T02:00:00Z","sport":"BRAZILSKA LIGA","league":"Fudbal","group":"381","isLive":false,"doNotMiss":false,"domain":"srb"}]}'
const result = parser({ channel, content }).map(p => {
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html'))
const result = parser({ channel, date, content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-11-16T23:30:00.000Z',
stop: '2021-11-17T01:30:00.000Z',
title: 'Crvena zvezda mts - Partizan NIS',
category: 'Ko\u0161arka',
description: 'ABA LIGA'
}
])
expect(result.length).toBe(19)
expect(result[4]).toMatchObject({
start: '2024-12-07T03:30:00.000Z',
stop: '2024-12-07T05:00:00.000Z',
title: 'EVROPSKO PRVENSTVO Ž',
description: 'Francuska - Crna Gora',
category: 'Rukomet',
})
expect(result[8]).toMatchObject({
start: '2024-12-07T11:00:00.000Z',
stop: '2024-12-07T11:05:00.000Z',
title: 'Arena News',
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: '{"channels":[]}'
content: ''
})
expect(result).toMatchObject([])
})