Merge pull request #2129 from liimee/astro

add season data to astro.com.my
This commit is contained in:
PopeyeTheSai10r 2023-07-09 08:34:08 -07:00 committed by GitHub
commit b9376f1a40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -7,7 +7,7 @@
"channelStbNumber": "305", "channelStbNumber": "305",
"isHd": true, "isHd": true,
"imageUrl": "https://s3-ap-southeast-1.amazonaws.com/ams-astro/production/images/1035X328883.jpg", "imageUrl": "https://s3-ap-southeast-1.amazonaws.com/ams-astro/production/images/1035X328883.jpg",
"title": "Triumph in the Skies Ep06", "title": "Triumph in the Skies S1 Ep06",
"programmeId": "328827", "programmeId": "328827",
"episodeId": "328883", "episodeId": "328883",
"datetime": "2022-10-31 00:10:00.0", "datetime": "2022-10-31 00:10:00.0",

View file

@ -21,7 +21,7 @@ module.exports = {
const stop = start.add(duration, 's') const stop = start.add(duration, 's')
const details = await loadProgramDetails(item) const details = await loadProgramDetails(item)
programs.push({ programs.push({
title: item.title, title: details.title,
sub_title: item.subtitles, sub_title: item.subtitles,
description: details.longSynopsis || details.shortSynopsis, description: details.longSynopsis || details.shortSynopsis,
actors: parseList(details.cast), actors: parseList(details.cast),
@ -30,6 +30,7 @@ module.exports = {
rating: parseRating(details), rating: parseRating(details),
categories: parseCategories(details), categories: parseCategories(details),
episode: parseEpisode(item), episode: parseEpisode(item),
season: parseSeason(details),
start: start, start: start,
stop: stop stop: stop
}) })
@ -45,6 +46,12 @@ function parseEpisode(item) {
return number ? parseInt(number) : null return number ? parseInt(number) : null
} }
function parseSeason(details) {
const [_, season] = details.title ? details.title.match(/ S(\d+)/) || [null, null] : [null, null]
return season ? parseInt(season) : null
}
function parseList(list) { function parseList(list) {
return typeof list === 'string' ? list.split(',') : [] return typeof list === 'string' ? list.split(',') : []
} }

View file

@ -49,7 +49,7 @@ it('can parse response', async () => {
expect(results[0]).toMatchObject({ expect(results[0]).toMatchObject({
start: '2022-10-30T16:10:00.000Z', start: '2022-10-30T16:10:00.000Z',
stop: '2022-10-30T17:02:00.000Z', stop: '2022-10-30T17:02:00.000Z',
title: 'Triumph in the Skies Ep06', title: 'Triumph in the Skies S1 Ep06',
description: description:
'This classic drama depicts the many aspects of two complicated relationships set against an airline company. Will those involved ever find true love?', 'This classic drama depicts the many aspects of two complicated relationships set against an airline company. Will those involved ever find true love?',
actors: ['Francis Ng Chun Yu', 'Joe Ma Tak Chung', 'Flora Chan Wai San'], actors: ['Francis Ng Chun Yu', 'Joe Ma Tak Chung', 'Flora Chan Wai San'],
@ -60,6 +60,7 @@ it('can parse response', async () => {
value: 'U' value: 'U'
}, },
episode: 6, episode: 6,
season: 1,
categories: ['Drama'] categories: ['Drama']
}) })
}) })