Update sky.com guide.

Test:

```sh
npm test -- /sky.com

> test
> run-script-os /sky.com

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

 PASS  sites/sky.com/sky.com.test.js
  √ can generate valid url (3 ms)
  √ can parse response (11 ms)
  √ can handle empty guide

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

Grab:

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

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

starting...
config:
  output: guide.xml
  maxConnections: 1
  gzip: false
  site: sky.com
loading channels...
  found 558 channel(s)
run #1:
  [1/1116] sky.com (en) - 1009 - Dec 14, 2024 (35 programs)
  [2/1116] sky.com (en) - 1009 - Dec 15, 2024 (34 programs)
  ...
  [1115/1116] sky.com (en) - SkySportsNews.uk - Dec 15, 2024 (26 programs)
  [1116/1116] sky.com (en) - TLCHD.uk - Dec 14, 2024 (30 programs)
  saving to "guide.xml"...
  done in 00h 04m 32s
```

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha 2024-12-15 03:46:36 +07:00
parent 581f5e0ca9
commit c54509f95e
No known key found for this signature in database
GPG key ID: 2D7AA6389D44DCAB
4 changed files with 1445 additions and 198 deletions

View file

@ -1,54 +1,59 @@
const { parser, url } = require('./sky.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-12-15', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2024-12-14', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '2002',
xmltv_id: 'BBCOneLondon.uk'
site_id: '4086',
xmltv_id: 'SkyHistoryHD.uk'
}
const content =
'{"listings":{"2002":[{"s":1639446600,"t":"Question of Sport","audioDescription":false,"m":[27170,1800,1,1,"--"],"rr":"S","subtitleHearing":true,"sid":53228,"d":"14/36. In this Christmas special, Paddy, Sam and Ugo are joined by Anton Du Beke, Shaun Wallace, Big Zuu and Jules Breach. Also in HD. [S]","img":"lisa/5.2.2/linear/channel/7f80ef03-3d8a-4f73-bf7d-6b03f410c7a8/2002"},{"s":1639448400,"t":"Weather for the Week Ahead","audioDescription":false,"m":[27171,300,1,1,"--"],"rr":"S","subtitleHearing":true,"sid":64799,"d":"Detailed weather forecast. Also in HD. [S]","img":"lisa/5.2.2/linear/channel/8fcf08b7-4081-499a-bf63-d100908e2d75/2002"}]}}'
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://epgservices.sky.com/5.2.2/api/2.0/channel/json/2002/1639526400/86400/4'
'https://awk.epgsky.com/hawk/linear/schedule/20241214/4086'
)
})
it('can parse response', () => {
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
const result = parser({ content, channel, date }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(result).toMatchObject([
{
start: '2021-12-14T01:50:00.000Z',
stop: '2021-12-14T02:20:00.000Z',
title: 'Question of Sport',
image:
'http://epgstatic.sky.com/epgdata/1.0/paimage/46/1/lisa/5.2.2/linear/channel/7f80ef03-3d8a-4f73-bf7d-6b03f410c7a8/2002'
},
{
start: '2021-12-14T02:20:00.000Z',
stop: '2021-12-14T02:25:00.000Z',
title: 'Weather for the Week Ahead',
image:
'http://epgstatic.sky.com/epgdata/1.0/paimage/46/1/lisa/5.2.2/linear/channel/8fcf08b7-4081-499a-bf63-d100908e2d75/2002'
}
])
expect(result.length).toBe(33)
expect(result[0]).toMatchObject({
start: '2024-12-13T22:00:00.000Z',
stop: '2024-12-13T23:00:00.000Z',
title: 'The UnXplained With...',
description:
'The Hunt for Jack the Ripper: Jack the Ripper\'s identity has eluded police, historians and armchair detectives for over a century. What do we know about the notorious killer? (S3, ep 21)',
season: 4,
episode: 14
})
expect(result[4]).toMatchObject({
start: '2024-12-14T01:00:00.000Z',
stop: '2024-12-14T01:30:00.000Z',
title: 'Storage Wars',
description:
'Not All That Glitters Is Gourd: Back in the city of Orange, the Vegas Ladies arrive in vintage style - though not everyone agrees. (S12, ep 6)',
season: 12,
episode: 6
})
})
it('can handle empty guide', () => {
const result = parser({
date,
channel,
content: '{"listings":{"2002":[]}}'
content: ''
})
expect(result).toMatchObject([])
})