Merge pull request #1448 from iptv-org/fix-rthk.hk

Fix rthk.hk
This commit is contained in:
Aleksandr Statciuk 2022-12-02 18:05:23 +03:00 committed by GitHub
commit b7c2ecdc79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -44,14 +44,14 @@ module.exports = {
}
function parseIcon($item) {
return $item('*').data('p')
return $item('.single-wrap').data('p')
}
function parseCategories($item) {
let cate = $item('*').data('cate')
let cate = $item('.single-wrap').data('cate') || ''
let [_, categories] = cate.match(/^\|(.*)\|$/) || [null, '']
return categories.split('||')
return categories.split('||').filter(Boolean)
}
function parseTitle($item) {

View file

@ -13,7 +13,7 @@ dayjs.extend(utc)
jest.mock('axios')
const date = dayjs.utc('2022-11-15', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2022-12-02', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '31',
xmltv_id: 'RTHKTV31.hk',
@ -21,7 +21,7 @@ const channel = {
}
it('can generate valid url', () => {
expect(url({ date })).toBe('https://www.rthk.hk/timetable/main_timetable/20221115')
expect(url({ date })).toBe('https://www.rthk.hk/timetable/main_timetable/20221202')
})
it('can generate valid request headers', () => {
@ -48,12 +48,12 @@ it('can parse response', () => {
})
expect(results[0]).toMatchObject({
start: '2022-11-14T16:00:00.000Z',
stop: '2022-11-14T16:30:00.000Z',
title: '救Bee大作戰',
sub_title: '第集',
categories: ['知識', '娛樂'],
icon: 'https://www.rthk.hk/assets/rthk/images/tv/player/480x272.jpg'
start: '2022-12-01T16:00:00.000Z',
stop: '2022-12-01T17:00:00.000Z',
title: '問天',
sub_title: '第十四集',
categories: ['戲劇'],
icon: 'https://www.rthk.hk/assets/images/rthk/dtt31/thegreataerospace/10239_1920_s.jpg'
})
})
@ -67,12 +67,12 @@ it('can parse response in English', () => {
})
expect(results[0]).toMatchObject({
start: '2022-11-14T16:00:00.000Z',
stop: '2022-11-14T16:30:00.000Z',
title: "Jimmy's Big Bee Rescue",
sub_title: 'Episode 2',
categories: ['知識', '娛樂'],
icon: 'https://www.rthk.hk/assets/rthk/images/tv/player/480x272.jpg'
start: '2022-12-01T16:00:00.000Z',
stop: '2022-12-01T17:00:00.000Z',
title: 'The Great Aerospace',
sub_title: 'Episode 14',
categories: ['戲劇'],
icon: 'https://www.rthk.hk/assets/images/rthk/dtt31/thegreataerospace/10239_1920_s.jpg'
})
})