Update starhubtvplus.com guide.

Test:

```sh
npm test -- starhubtvplus.com

> test
> run-script-os starhubtvplus.com

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

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

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        4.337 s
Ran all test suites matching /starhubtvplus.com/i.
```

Grab:

```sh
npm run grab -- --site=starhubtvplus.com --lang=en

> grab
> npx tsx scripts/commands/epg/grab.ts --site=starhubtvplus.com --lang=en

starting...
config:
  output: guide.xml
  maxConnections: 1
  gzip: false
  site: starhubtvplus.com
  lang: en
loading channels...
  found 116 channel(s)
run #1:
  [1/232] starhubtvplus.com (en) - 7c0ee1eb-5f74-4f5a-a338-69eb125badb4 - Dec 4, 2024 (26 programs)
  [2/232] starhubtvplus.com (en) - 7c0ee1eb-5f74-4f5a-a338-69eb125badb4 - Dec 5, 2024 (26 programs)
  ...
  [231/232] starhubtvplus.com (en) - 210ba103-0d19-4b26-bb9f-36d531d7471f - Dec 5, 2024 (39 programs)
  [232/232] starhubtvplus.com (en) - 210ba103-0d19-4b26-bb9f-36d531d7471f - Dec 4, 2024 (39 programs)
  saving to "guide.xml"...
  done in 00h 00m 22s
```

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha committed 2024-12-04 20:56:00 +07:00
1 parent 864e0ac2c4
commit 4c706f49a4
7 files changed
+359 -242

No files matched your search

@@ -2,38 +2,28 @@ const { parser, url, request } = require('./starhubtvplus.com.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('2022-05-10', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2024-12-04', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '102',
xmltv_id: 'Channel5.sg'
lang: 'en',
site_id: 'd258444e-b66b-4cbe-88db-e09f31ab8a1f',
xmltv_id: 'AXN.sg'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://api.starhubtvplus.com/epg?operationName=webFilteredEpg&variables=%7B%22category%22%3A%22%22%2C%22dateFrom%22%3A%222022-05-10%22%2C%22dateTo%22%3A%222022-05-11%22%7D&query=query%20webFilteredEpg(%24category%3A%20String%2C%20%24dateFrom%3A%20DateWithoutTime%2C%20%24dateTo%3A%20DateWithoutTime!)%20%7B%20nagraEpg(category%3A%20%24category)%20%7B%20items%20%7B%20id%3A%20tvChannel%20image%20name%3A%20longName%20programs%3A%20programsByDate(dateFrom%3A%20%24dateFrom%2C%20dateTo%3A%20%24dateTo)%20%7B%20id%20title%20description%20Categories%20startTime%20endTime%20%7D%7D%7D%7D'
'https://waf-starhub-metadata-api-p001.ifs.vubiquity.com/v3.1/epg/schedules?locale=en_US&locale_default=en_US&device=1&in_channel_id=d258444e-b66b-4cbe-88db-e09f31ab8a1f&gt_end=1733270400&lt_start=1733356800&limit=100&page=1'
)
})
it('can generate valid request headers', () => {
expect(request.headers).toMatchObject({
'x-application-key': '5ee2ef931de1c4001b2e7fa3_5ee2ec25a0e845001c1783dc',
'x-application-session': '01G2QG0N3RWDNCBA1S5MK1MD2K17CE4431A2'
})
})
it('can generate valid cache settings', () => {
expect(request.cache).toMatchObject({
ttl: 60 * 60 * 1000
})
})
it('can parse response', () => {
const content =
'{"data":{"nagraEpg":{"items":[{"id":102,"name":"Channel 5 HD_DASH","programs":[{"id":"GLOBAL_TC0021650123","title":"Luke Nguyen\'s Vietnam","description":"Luke leaves the hustle and bustle of Hanoi behind for the mystical mountains of Sapa. There, he prepares some black chicken in and amongst the local streets. He cooks buffalo for a salad in the busy Sapa markets, as well as a tofu-and-tomato dish high up in the rice paddy fields with the most spectacular backdrop.","Categories":["Others"],"startTime":1652110200000,"endTime":1652112000000}]}]}}}'
const result = parser({ content, channel }).map(p => {
it('can parse response', async () => {
const fs = require('fs')
const path = require('path')
const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.json'))
const result = (await parser({ content, date, channel })).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
@@ -41,20 +31,22 @@ it('can parse response', () => {
expect(result).toMatchObject([
{
start: '2022-05-09T15:30:00.000Z',
stop: '2022-05-09T16:00:00.000Z',
title: "Luke Nguyen's Vietnam",
start: '2024-12-03T17:25:00.000Z',
stop: '2024-12-03T18:20:00.000Z',
title: 'Northern Rexposure',
subTitle: 'Hudson & Rex (Season 5)',
description:
'Luke leaves the hustle and bustle of Hanoi behind for the mystical mountains of Sapa. There, he prepares some black chicken in and amongst the local streets. He cooks buffalo for a salad in the busy Sapa markets, as well as a tofu-and-tomato dish high up in the rice paddy fields with the most spectacular backdrop.',
category: ['Others']
'When Jesse\'s sister contacts him for help, he, Sarah and Rex head to Northern Ontario and find themselves in the middle of a deadly situation.',
category: ['Drama'],
image: ['https://poster.starhubgo.com/poster/ch511_hudson_rex5.jpg?w=960&h=540', 'https://poster.starhubgo.com/poster/ch511_hudson_rex5.jpg?w=341&h=192'],
season: 5,
episode: 15,
rating: 'PG13'
}
])
})
it('can handle empty guide', () => {
const result = parser({
content:
'{"errors":[{"code":"A9999","message":"Syntax, request headers or server error","extendedLogging":{"message":"Cannot read property \'operation\' of undefined"}}]}'
})
it('can handle empty guide', async () => {
const result = await parser({ content: '' })
expect(result).toMatchObject([])
})